html5 datetime instead of jquery
anhang pdf rechnung
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Controllers;
|
||||
use App\Models\mBills;
|
||||
use App\Models\mAccounts;
|
||||
use CodeIgniter\Session\Session;
|
||||
use CodeIgniter\Files\File;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class Home extends BaseController
|
||||
{
|
||||
@@ -157,9 +159,38 @@ class Home extends BaseController
|
||||
// }
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function viewBill($filename) {
|
||||
$filePath= WRITEPATH . '/uploads';
|
||||
$file = new \CodeIgniter\Files\File($filePath."/".$filename);
|
||||
log_message('debug',$file->getMimeType());
|
||||
if ($file->getMimeType() == 'application/pdf')
|
||||
$this->viewPdf($filename);
|
||||
else
|
||||
return view('viewBillImg', ['filename'=>WRITEPATH . '/uploads'.$filename]);
|
||||
}
|
||||
|
||||
public function viewPdf($filename) {
|
||||
$view = \Config\Services::renderer();
|
||||
log_message('debug',$filename);
|
||||
$filePath= WRITEPATH . '/uploads';
|
||||
header("Cache-Control: maxage=1");
|
||||
header("Pragma: public");
|
||||
header('Content-type:application/pdf');
|
||||
header('Content-disposition: inline; filename="'.$filename.'"');
|
||||
header('content-Transfer-Encoding:binary');
|
||||
header('Content-Length:' .filesize($filePath."/".$filename));
|
||||
if (($pdf =file_get_contents($filePath."/".$filename)) === false)
|
||||
print $filePath."/".$filename;
|
||||
else
|
||||
print $pdf;
|
||||
exit;
|
||||
}
|
||||
|
||||
public function attemptNewBilling()
|
||||
{
|
||||
helper('form');
|
||||
$uploading = false;
|
||||
$rules = [
|
||||
'source' => 'required|greater_than[0]',
|
||||
'datum' => 'required',
|
||||
@@ -170,22 +201,38 @@ class Home extends BaseController
|
||||
'source' => ['required' => 'Konto fehlt','greater_than' => 'Konto fehlt'],
|
||||
'datum' => ['required' => 'Datum fehlt']];
|
||||
// 'totalamount' => ['required' => 'Betrag fehlt','numeric' => 'Betrag muss eine Zahl sein']];
|
||||
if ( 'on' == $this->request->getPost('multi') )
|
||||
{
|
||||
if ( 'on' == $this->request->getPost('multi') ) {
|
||||
$rules['openamount'] = 'equals[0]';
|
||||
$errors['openamount'] = ['equals' => 'Betrag muss 0 sein'];
|
||||
}
|
||||
|
||||
$fehler= array();
|
||||
$valid = $this->customValidation($fehler);
|
||||
$file = $this->request->getFile('billfile');
|
||||
if ($file) {
|
||||
if (! $file->isValid() && ($file->getError() != UPLOAD_ERR_NO_FILE)) {
|
||||
throw new \RuntimeException($file->getErrorString() . '(' . $file->getError() . ')');
|
||||
} else if ($file->isValid()) {
|
||||
$rules['billfile'] = ['uploaded[billfile]','max_size[billfile,10000]','mime_in[billfile,application/pdf]'];
|
||||
$errors['billfile'] = ['uploaded'=>'Fehler beim Upload','max_size' => 'Zu Groß', 'mime_in' => "Ungültiger Datentyp"];
|
||||
$uploading = true;
|
||||
}
|
||||
}
|
||||
if ((! $this->validate($rules,$errors)) || (!$valid)){
|
||||
return $this->newBill($this->request->getPost(), array_merge($this->validator->getErrors(),$fehler),$this->request->getPost('scheduled'));
|
||||
// return redirect()->back()->withInput()->with('errors', $validation->getErrors());
|
||||
}
|
||||
else{
|
||||
$data = $this->request->getPost();
|
||||
//log_message('debug',print_r($data,true));
|
||||
if ($this->request->getPost('scheduled') =="0"){
|
||||
$bills = model('App\Models\mBills');
|
||||
$bills->saveBill($this->request->getPost());
|
||||
if ($uploading){
|
||||
$date = Time::parse($this->request->getPost('datum'));
|
||||
$file->move(WRITEPATH . 'uploads',$date->toLocalizedString('yyyyMMdd')." ".$this->request->getPost('receiver')." ".$this->request->getPost("comment[0]").".".$file->guessExtension());
|
||||
$data['rechnung'] = $file->getName();
|
||||
log_message('debug', $file->getName());
|
||||
}
|
||||
$bills = model('App\Models\mBills');
|
||||
$bills->saveBill($data);
|
||||
$redirectURL = session('redirect_url') ?? site_url('/');
|
||||
unset($_SESSION['redirect_url']);
|
||||
return redirect()->to($redirectURL);
|
||||
|
||||
Reference in New Issue
Block a user