Beispiel #1
0
 protected function post_id_line_type_handler()
 {
     $this->connection->selectDB($this->config->get('OP_DB'));
     $model = new CustomReceiptModel($this->connection);
     $model->type($this->type);
     try {
         $delete = $this->form->del;
     } catch (Exception $ex) {
         $delete = array();
     }
     $currentID = 0;
     for ($i = 0; $i < count($this->id); $i++) {
         $postedID = $this->id[$i];
         $line = $this->line[$i];
         if (!in_array($postedID, $delete)) {
             $model->seq($currentID);
             $model->text($line);
             $model->save();
             $currentID++;
         }
     }
     try {
         $new = $this->form->newLine;
         if (!empty($new)) {
             $model->seq($currentID);
             $model->text($new);
             $model->save();
             $currentID++;
         }
     } catch (Exception $ex) {
     }
     $trimP = $this->connection->prepare('
         DELETE 
         FROM customReceipt
         WHERE type=?
             AND seq >= ?
     ');
     $this->connection->execute($trimP, array($this->type, $currentID));
     return $this->get_type_handler();
 }