if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; } $langs->load('bills'); $langs->load('banks'); $langs->load('companies'); // Security check $id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int'); $action = GETPOST("action"); $confirm = GETPOST('confirm'); if ($user->societe_id) { $socid = $user->societe_id; } // TODO Add rule to restrict access payment //$result = restrictedArea($user, 'facture', $id,''); $payment = new PaymentExpenseReport($db); if ($id > 0) { $result = $payment->fetch($id); if (!$result) { dol_print_error($db, 'Failed to get payment id ' . $id); } } /* * Actions */ // Delete payment if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensereport->supprimer) { $db->begin(); $result = $payment->delete($user); if ($result > 0) { $db->commit();
/** * Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone * @return int New id of clone */ function createFromClone($fromid) { global $user, $langs; $error = 0; $object = new PaymentExpenseReport($this->db); $object->context['createfromclone'] = 'createfromclone'; $this->db->begin(); // Load source object $object->fetch($fromid); $object->id = 0; $object->statut = 0; // Clear fields // ... // Create clone $result = $object->create($user); // Other options if ($result < 0) { $this->error = $object->error; $error++; } if (!$error) { } unset($this->context['createfromclone']); // End if (!$error) { $this->db->commit(); return $object->id; } else { $this->db->rollback(); return -1; } }
// Read possible payments foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_') { $other_chid = substr($key, 7); $amounts[$other_chid] = price2num($_POST[$key]); $total += price2num($_POST[$key]); } } if (count($amounts) <= 0) { $error++; $errmsg = 'ErrorNoPaymentDefined'; } if (!$error) { $db->begin(); // Create a line of payments $payment = new PaymentExpenseReport($db); $payment->chid = $chid; $payment->datepaid = $datepaid; $payment->amounts = $amounts; // Tableau de montant $payment->total = $total; $payment->fk_typepayment = $_POST["fk_typepayment"]; $payment->num_payment = $_POST["num_payment"]; $payment->note = $_POST["note"]; if (!$error) { $paymentid = $payment->create($user); if ($paymentid < 0) { $errmsg = $payment->error; $error++; } }