diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 5bf528d..1f7d68d 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -40,7 +40,9 @@ $routes->get('Ajax/(:segment)', 'Ajax::$1'); $routes->post('Ajax/(:segment)', 'Ajax::$1'); $routes->get('newBill', 'Home::newBill'); $routes->get('newTransfer', 'Home::newTransfer'); -$routes->get('newScheduled', 'Home::newScheduled'); +$routes->get('newScheduled', 'Home::newScheduled/0'); +$routes->get('newScheduledTransfer', 'Home::newScheduled/1'); + $routes->post('newBill', 'Home::attemptNewBilling'); $routes->post('editAccount', 'Home::attemptEditAccount'); diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 2e3d5fb..4eed9e4 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -72,8 +72,15 @@ class Home extends BaseController return $data; } - public function newScheduled(){ - return $this->newBill(NULL,NULL,true); + /** + * Legt eine neue Terminbuchung an + * @param bool $transfer ob Terminbuchung vom Typ Transfer ist + * @return char gibt die View zurück + **/ + public function newScheduled($transfer = 0){ + $data = $this->loadFormDefaults(); + $data['transfer'] = (bool)$transfer; + return $this->newBill($data,NULL,true); } public function newTransfer(){ @@ -94,10 +101,11 @@ class Home extends BaseController $data['scheduled'] = array('NumList' => array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6'), 'TypeList' => array('week'=>'Woche(n)','month'=>'Monat(e)','year'=>'Jahr(e)'), 'style' => 'class="form-select"'); - if (!$data['transfer']) - $categories = $this->accounts->getDropDownLists( 'InOut', TRUE ); - else + if ($data['transfer']) $categories = $this->accounts->getDropDownLists( 'Acc', TRUE ); + else + $categories = $this->accounts->getDropDownLists( 'InOut', TRUE ); + // $data['catparentlist'] = $categories['parent']; // if (!array_key_exists('catparent', $data)) // $data['catparent'] = $this->accounts->getParent($data['cat']); diff --git a/app/Models/mScheduled.php b/app/Models/mScheduled.php index 92d3e6a..3584f01 100644 --- a/app/Models/mScheduled.php +++ b/app/Models/mScheduled.php @@ -57,11 +57,19 @@ class mScheduled extends Model { } public function saveBill($data){ + $accounts = model('App\Models\mAccounts'); $data['validate'] = true; $data['scheduled'] = true; $data['renummer'] = isset($data['renummer']); - $data['multi'] = isset($data['multiple']); - $data['transfer'] = false; + + if ($data['transfer']==1){ + $data['receiver'] = $accounts->getDropDownEntry($data['category'][0]); + $data['transfer'] = true; + } + else{ + $data['multi'] = isset($data['multiple']); + $data['transfer'] = false; + } unset($data['openamount']); unset($data['category_parent']); $data['datum'] = date( "Y-m-d", strtotime($data['datum'] ) ); diff --git a/public/js/scheduled.js b/public/js/scheduled.js index 1cd2ba9..14a80b3 100644 --- a/public/js/scheduled.js +++ b/public/js/scheduled.js @@ -13,9 +13,9 @@ $(document).ready(function(){ dom: '<"toolbar">frt', columns: columnspez }); - $("div.toolbar").html('Neuer Eintrag'); + $("div.toolbar").html('Neue RechnungNeuer Transfer'); $('#scheduled tbody').on('click', 'td.dt-receiver', function () {collapseDetails($(this), datatable);} ); $('#scheduled tbody').on('click', 'td.dt-datum', function () {location.href = '/editScheduled/'+getId($(this),datatable);}); $('#scheduled tbody').on('click', 'table.tabdet', function () {location.href = '/editScheduled/'+$(this).attr('data-bs-id');}); -}); \ No newline at end of file +});