/** * Create in database * * @param User $user User that create * @return int <0 if KO, >0 if OK */ function create($user) { global $conf, $langs; $error = 0; // Clean parameters $this->amount = price2num(trim($this->amount)); $this->label = trim($this->label); $this->note = trim($this->note); $this->fk_bank = trim($this->fk_bank); $this->fk_user_creat = trim($this->fk_user_creat); $this->fk_user_modif = trim($this->fk_user_modif); // Check parameters if (!$this->label) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } if ($this->fk_user < 0 || $this->fk_user == '') { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); return -4; } if ($this->amount < 0 || $this->amount == '') { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -5; } if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); return -6; } if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); return -7; } $this->db->begin(); // Insert into llx_payment_salary $sql = "INSERT INTO " . MAIN_DB_PREFIX . "payment_salary (fk_user"; $sql .= ", datep"; $sql .= ", datev"; $sql .= ", amount"; $sql .= ", fk_typepayment"; $sql .= ", num_payment"; if ($this->note) { $sql .= ", note"; } $sql .= ", label"; $sql .= ", datesp"; $sql .= ", dateep"; $sql .= ", fk_user_creat"; $sql .= ", fk_bank"; $sql .= ", entity"; $sql .= ") "; $sql .= " VALUES ("; $sql .= "'" . $this->fk_user . "'"; $sql .= ", '" . $this->db->idate($this->datep) . "'"; $sql .= ", '" . $this->db->idate($this->datev) . "'"; $sql .= ", '" . $this->amount . "'"; $sql .= ", '" . $this->type_payment . "'"; $sql .= ", '" . $this->num_payment . "'"; if ($this->note) { $sql .= ", '" . $this->db->escape($this->note) . "'"; } $sql .= ", '" . $this->db->escape($this->label) . "'"; $sql .= ", '" . $this->db->idate($this->datesp) . "'"; $sql .= ", '" . $this->db->idate($this->dateep) . "'"; $sql .= ", '" . $user->id . "'"; $sql .= ", NULL"; $sql .= ", " . $conf->entity; $sql .= ")"; dol_syslog(get_class($this) . "::create", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "payment_salary"); if ($this->id > 0) { if (!empty($conf->banque->enabled) && !empty($this->amount)) { // Insert into llx_bank require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $acc = new Account($this->db); $result = $acc->fetch($this->accountid); if ($result <= 0) { dol_print_error($this->db); } // Insert payment into llx_bank // Add link 'payment_salary' in bank_url between payment and bank transaction $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), $this->num_payment, '', $user); // Update fk_bank into llx_paiement. // So we know the payment which has generate the banking ecriture if ($bank_line_id > 0) { $this->update_fk_bank($bank_line_id); } else { $this->error = $acc->error; $error++; } if (!$error) { // Add link 'payment_salary' in bank_url between payment and bank transaction $url = DOL_URL_ROOT . '/compta/salaries/card.php?id='; $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); if ($result <= 0) { $this->error = $acc->error; $error++; } } $fuser = new User($this->db); $fuser->fetch($this->fk_user); // Add link 'user' in bank_url between operation and bank transaction $result = $acc->add_url_line($bank_line_id, $this->fk_user, DOL_URL_ROOT . '/user/card.php?id=', $langs->trans("SalaryPayment") . ' ' . $fuser->getFullName($langs) . ' ' . dol_print_date($this->datesp, 'dayrfc') . ' ' . dol_print_date($this->dateep, 'dayrfc'), 'user'); if ($result <= 0) { $this->error = $acc->error; $error++; } } // Call trigger $result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } else { $error++; } if (!$error) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); return -2; } } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; } }
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), "errors"); } if (!GETPOST('account_from', 'int')) { $error = 1; setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferFrom")), "errors"); } if (!GETPOST('account_to', 'int')) { $error = 1; setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferTo")), "errors"); } if (!$error) { require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $accountfrom = new Account($db); $accountfrom->fetch($_POST["account_from"]); $accountto = new Account($db); $accountto->fetch($_POST["account_to"]); if ($accountto->id != $accountfrom->id) { $db->begin(); $error = 0; $bank_line_id_from = 0; $bank_line_id_to = 0; $result = 0; // By default, electronic transfert from bank to bank $typefrom = 'PRE'; $typeto = 'VIR'; if ($accountto->courant == 2 || $accountfrom->courant == 2) { // This is transfert of change $typefrom = 'LIQ'; $typeto = 'LIQ'; } if (!$error) {
/** * Show miscellaneous information (payment mode, payment term, ...) * * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object * @return void */ function _tableau_info(&$pdf, $object, $posy, $outputlangs) { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); $posy = $pdf->GetY() + 4; } $posxval = 52; // Show payments conditions if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions") . ':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement = str_replace('\\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); $posy = $pdf->GetY() + 3; } if ($object->type != 2) { // Check a payment mode is defined if (empty($object->mode_reglement_code) && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($conf->global->FACTURE_RIB_NUMBER)) { $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"); } elseif ($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) || $object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER)) { $outputlangs->load("errors"); $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetTextColor(200, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code); $pdf->MultiCell(80, 3, $this->error, 0, 'L', 0); $pdf->SetTextColor(0, 0, 0); $posy = $pdf->GetY() + 1; } // Show payment mode if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode") . ':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) != 'PaymentType' . $object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; } // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { $diffsizetitle = empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE; if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_CHQ_NUMBER); $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $posy = $pdf->GetY() + 2; } } } } // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) { $bankid = empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account; if (!empty($object->fk_bank)) { $bankid = $object->fk_bank; } // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); $curx = $this->marge_gauche; $cury = $posy; $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); $posy += 2; } } } return $posy; }
/** * Add a record into bank for payment with links between this bank record and invoices of payment. * All payment properties (this->amount, this->amounts, ...) must have been set first like after a call to create(). * * @param User $user Object of user making payment * @param string $mode 'payment', 'payment_supplier' * @param string $label Label to use in bank record * @param int $accountid Id of bank account to do link with * @param string $emetteur_nom Name of transmitter * @param string $emetteur_banque Name of bank * @param int $notrigger No trigger * @return int <0 if KO, bank_line_id if OK */ function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0) { global $conf, $langs, $user; $error = 0; $bank_line_id = 0; if (!empty($conf->banque->enabled)) { if ($accountid <= 0) { $this->error = 'Bad value for parameter accountid'; dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->error, LOG_ERR); return -1; } $this->db->begin(); $this->fk_account = $accountid; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; dol_syslog("{$user->id},{$mode},{$label},{$this->fk_account},{$emetteur_nom},{$emetteur_banque}"); $acc = new Account($this->db); $result = $acc->fetch($this->fk_account); $totalamount = $this->amount; if (empty($totalamount)) { $totalamount = $this->total; } // For backward compatibility if ($mode == 'payment_supplier') { $totalamount = -$totalamount; } // Insert payment into llx_bank $bank_line_id = $acc->addline($this->datepaye, $this->paiementid, $label, $totalamount, $this->num_paiement, '', $user, $emetteur_nom, $emetteur_banque); // Mise a jour fk_bank dans llx_paiement // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; dol_print_error($this->db); } // Add link 'payment', 'payment_supplier' in bank_url between payment and bank transaction if (!$error) { $url = ''; if ($mode == 'payment') { $url = DOL_URL_ROOT . '/compta/paiement/card.php?id='; } if ($mode == 'payment_supplier') { $url = DOL_URL_ROOT . '/fourn/paiement/card.php?id='; } if ($url) { $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; dol_print_error($this->db); } } } // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) if (!$error && $label != '(WithdrawalPayment)') { $linkaddedforthirdparty = array(); foreach ($this->amounts as $key => $value) { if ($mode == 'payment') { $fac = new Facture($this->db); $fac->fetch($key); $fac->fetch_thirdparty(); if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) { $result = $acc->add_url_line($bank_line_id, $fac->thirdparty->id, DOL_URL_ROOT . '/comm/card.php?socid=', $fac->thirdparty->name, 'company'); if ($result <= 0) { dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->db->lasterror()); } $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id; // Mark as done for this thirdparty } } if ($mode == 'payment_supplier') { $fac = new FactureFournisseur($this->db); $fac->fetch($key); $fac->fetch_thirdparty(); if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) { $result = $acc->add_url_line($bank_line_id, $fac->thirdparty->id, DOL_URL_ROOT . '/fourn/card.php?socid=', $fac->thirdparty->name, 'company'); if ($result <= 0) { dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->db->lasterror()); } $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id; // Mark as done for this thirdparty } } } } if (!$error && !$notrigger) { // Appel des triggers $result = $this->call_trigger('PAYMENT_ADD_TO_BANK', $user); if ($result < 0) { $error++; } // Fin appel triggers } } else { $this->error = $acc->error; $error++; } if (!$error) { $this->db->commit(); } else { $this->db->rollback(); } } if (!$error) { return $bank_line_id; } else { return -1; } }
*/ llxHeader(); $societestatic = new Societe($db); $facturestatic = new Facture($db); $facturefournstatic = new FactureFournisseur($db); $socialcontribstatic = new ChargeSociales($db); $form = new Form($db); if ($_REQUEST["account"] || $_REQUEST["ref"]) { if ($vline) { $viewline = $vline; } else { $viewline = 20; } $acct = new Account($db); if ($_GET["account"]) { $result = $acct->fetch($_GET["account"]); } if ($_GET["ref"]) { $result = $acct->fetch(0, $_GET["ref"]); $_GET["account"] = $acct->id; } // Onglets $head = bank_prepare_head($acct); dol_fiche_head($head, 'cash', $langs->trans("FinancialAccount"), 0, 'account'); print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/compta/bank/index.php">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td width="25%">' . $langs->trans("Ref") . '</td>'; print '<td colspan="3">'; print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref'); print '</td></tr>';
dol_fiche_head($tabs, 0, $langs->trans('LineRecord'), 0, 'account'); $sql = "SELECT b.rowid,b.dateo as do,b.datev as dv, b.amount, b.label, b.rappro,"; $sql .= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,"; $sql .= " b.emetteur,b.banque"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " WHERE rowid=" . $rowid; $sql .= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { $i = 0; $total = 0; if ($db->num_rows($result)) { $objp = $db->fetch_object($result); $total = $total + $objp->amount; $acct = new Account($db); $acct->fetch($objp->fk_account); $account = $acct->id; $bankline = new AccountLine($db); $bankline->fetch($rowid, $ref); $links = $acct->get_url($rowid); $bankline->load_previous_next_ref('', 'rowid'); // Confirmations if ($action == 'delete_categ') { print $form->formconfirm($_SERVER['PHP_SELF'] . "?rowid=" . $rowid . "&cat1=" . GETPOST("fk_categ") . "&orig_account=" . $orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); } print '<form name="update" method="POST" action="' . $_SERVER['PHP_SELF'] . '?rowid=' . $rowid . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="orig_account" value="' . $orig_account . '">'; print '<input type="hidden" name="id" value="' . $acct->id . '">'; print '<table class="border" width="100%">';
if ($account) { if (!preg_match('/,/', $account)) { $moreparam = '&month=' . $month . '&year=' . $year . ($mode == 'showalltime' ? '&mode=showalltime' : ''); if ($_GET["option"] != 'all') { $morehtml = '<a href="' . $_SERVER["PHP_SELF"] . '?account=' . $account . '&option=all' . $moreparam . '">' . $langs->trans("ShowAllAccounts") . '</a>'; print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam); } else { $morehtml = '<a href="' . $_SERVER["PHP_SELF"] . '?account=' . $account . $moreparam . '">' . $langs->trans("BackToAccount") . '</a>'; print $langs->trans("All"); //print $morehtml; } } else { $bankaccount = new Account($db); $listid = explode(',', $account); foreach ($listid as $key => $id) { $bankaccount->fetch($id); $bankaccount->label = $bankaccount->ref; print $bankaccount->getNomUrl(1); if ($key < count($listid) - 1) { print ', '; } } } } else { print $langs->trans("All"); } print '</td></tr>'; // Label print '<tr><td>' . $langs->trans("Label") . '</td>'; print '<td colspan="3">'; if ($account && $_GET["option"] != 'all') {
/** * \brief Affiche infos divers * \param pdf Objet PDF * \param object Objet commande * \param posy Position depart * \param outputlangs Objet langs * \return y Position pour suite */ function _tableau_info(&$pdf, $object, $posy, $outputlangs) { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('','', $default_font_size - 1); // If France, show VAT mention if not applicable if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) { $pdf->SetFont('','B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); $posy=$pdf->GetY()+4; } // Show payments conditions if ($object->cond_reglement_code || $object->cond_reglement) { $pdf->SetFont('','B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY(52, $posy); $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); $posy=$pdf->GetY()+3; } // Check a payment mode is defined /* Not used with orders if (empty($object->mode_reglement_code) && ! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetTextColor(200,0,0); $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); $pdf->SetTextColor(0,0,0); $posy=$pdf->GetY()+1; }*/ // Show payment mode if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { $pdf->SetFont('','B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY(50, $posy); //print "xxx".$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code);exit; $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); $posy=$pdf->GetY()+2; } // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if ($conf->global->FACTURE_CHQ_NUMBER) { if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_CHQ_NUMBER); $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0); $posy=$pdf->GetY()+1; $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('','', $default_font_size - 2); $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); $posy=$pdf->GetY()+2; } if ($conf->global->FACTURE_CHQ_NUMBER == -1) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->name).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); $posy=$pdf->GetY()+1; $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('','', $default_font_size - 2); $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $posy=$pdf->GetY()+2; } } } // If payment mode not forced or forced to VIR, show payment with BAN /* Not enough space if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { if (! empty($conf->global->FACTURE_RIB_NUMBER)) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_RIB_NUMBER); $curx=$this->marge_gauche; $cury=$posy; $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); $posy+=2; } } */ return $posy; }
/** * Add record into bank for payment with links between this bank record and invoices of payment. * All payment properties must have been set first like after a call to create(). * @param user Object of user making payment * @param mode 'payment_sc' * @param label Label to use in bank record * @param accountid Id of bank account to do link with * @param emetteur_nom Name of transmitter * @param emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque) { global $conf; $error=0; if ($conf->banque->enabled) { require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'); $acc = new Account($this->db); $acc->fetch($accountid); $total=$this->total; if ($mode == 'payment_sc') $total=-$total; // Insert payment into llx_bank $bank_line_id = $acc->addline($this->datepaye, $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") $label, $total, $this->num_paiement, '', $user, $emetteur_nom, $emetteur_banque); // Mise a jour fk_bank dans llx_paiement. // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { $result=$this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; dol_print_error($this->db); } // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction $url=''; if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='; if ($url) { $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; dol_print_error($this->db); } } // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) $linkaddedforthirdparty=array(); foreach ($this->amounts as $key => $value) { if ($mode == 'payment_sc') { $socialcontrib = new ChargeSociales($this->db); $socialcontrib->fetch($key); $result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc'); if ($result <= 0) dol_print_error($this->db); } } } else { $this->error=$acc->error; $error++; } } if (! $error) { return 1; } else { return -1; } }
} $canbedeleted = $account->can_be_deleted(); // Renvoi vrai si compte sans mouvements if ($user->rights->banque->configurer && $canbedeleted) { print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $account->id . '">' . $langs->trans("Delete") . '</a>'; } print '</div>'; } /* ************************************************************************** */ /* */ /* Edition */ /* */ /* ************************************************************************** */ if (GETPOST('id', 'int') && $action == 'edit' && $user->rights->banque->configurer) { $account = new Account($db); $account->fetch(GETPOST('id', 'int')); print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'title_bank.png'); if ($conf->use_javascript_ajax) { print "\n" . '<script type="text/javascript" language="javascript">'; print 'jQuery(document).ready(function () { jQuery("#selecttype").change(function() { document.formsoc.action.value="edit"; document.formsoc.submit(); }); })' . "\n"; print 'jQuery(document).ready(function () { jQuery("#selectaccount_country_id").change(function() { document.formsoc.action.value="edit"; document.formsoc.submit(); }); })';
if ($date_start && $date_end) { $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; } $sql .= " ORDER BY b.datev"; $object = new Account($db); $paymentstatic = new Paiement($db); $paymentsupplierstatic = new PaiementFourn($db); $societestatic = new Societe($db); $userstatic = new User($db); $chargestatic = new ChargeSociales($db); $paymentdonstatic = new PaymentDonation($db); $paymentvatstatic = new TVA($db); $paymentsalstatic = new PaymentSalary($db); // Get code of finance journal $bank_code_journal = new Account($db); $result = $bank_code_journal->fetch($id_bank_account); $journal = $bank_code_journal->accountancy_journal; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); // Variables $cptfour = !empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); $cptcli = !empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); $accountancy_account_salary = !empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"); $accountancy_account_pay_vat = !empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : $langs->trans("CodeNotDef"); $accountancy_account_pay_donation = !empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef"); $tabpay = array(); $tabbq = array(); $tabtp = array(); $tabtype = array();
/** * Build document * @param model Model name * @param outputlangs Object langs * @return int <0 if KO, >0 if OK */ function generatePdf($model = 'blochet', $outputlangs) { global $langs, $conf; if (empty($model)) { $model = 'blochet'; } dol_syslog("RemiseCheque::generatePdf model=" . $model . " id=" . $this->id, LOG_DEBUG); $dir = DOL_DOCUMENT_ROOT . "/includes/modules/cheque/pdf/"; // Charge le modele $file = "pdf_" . $model . ".class.php"; if (file_exists($dir . $file)) { require_once DOL_DOCUMENT_ROOT . "/compta/bank/class/account.class.php"; require_once $dir . $file; $classname = 'BordereauCheque' . ucfirst($model); $docmodel = new $classname($db); $sql = "SELECT b.banque, b.emetteur, b.amount, b.num_chq"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= ", " . MAIN_DB_PREFIX . "bank_account as ba"; $sql .= ", " . MAIN_DB_PREFIX . "bordereau_cheque as bc"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND b.fk_bordereau = bc.rowid"; $sql .= " AND bc.rowid = " . $this->id; $sql .= " AND bc.entity = " . $conf->entity; $sql .= " ORDER BY b.emetteur ASC, b.rowid ASC;"; dol_syslog("RemiseCheque::generatePdf sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $i = 0; while ($objp = $this->db->fetch_object($result)) { $docmodel->lines[$i]->bank_chq = $objp->banque; $docmodel->lines[$i]->emetteur_chq = $objp->emetteur; $docmodel->lines[$i]->amount_chq = $objp->amount; $docmodel->lines[$i]->num_chq = $objp->num_chq; $i++; } } $docmodel->nbcheque = $this->nbcheque; $docmodel->number = $this->number; $docmodel->amount = $this->amount; $docmodel->date = $this->date_bordereau; $account = new Account($this->db); $account->fetch($this->account_id); $docmodel->account =& $account; // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output = $outputlangs->charset_output; $result = $docmodel->write_file($conf->banque->dir_output . '/bordereau', $this->number, $outputlangs); if ($result > 0) { $outputlangs->charset_output = $sav_charset_output; return 1; } else { $outputlangs->charset_output = $sav_charset_output; dol_syslog("Error"); dol_print_error($db, $docmodel->error); return 0; } } else { $this->error = $langs->trans("ErrorFileDoesNotExists", $dir . $file); return -1; } }
* View */ $form=new Form($db); llxHeader(); $societestatic=new Societe($db); $chargestatic=new ChargeSociales($db); $memberstatic=new Adherent($db); $paymentstatic=new Paiement($db); $paymentsupplierstatic=new PaiementFourn($db); $paymentvatstatic=new TVA($db); $acct = new Account($db); $acct->fetch($_GET["account"]); $now=dol_now(); $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " WHERE rappro=0 AND fk_account=".$_GET["account"]; $sql.= " ORDER BY dateo ASC"; $sql.= " LIMIT 1000"; // Limit to avoid page overload $resql = $db->query($sql); if ($resql) { $var=True; $num = $db->num_rows($resql);
print '<tr class="liste_titre">'; print '<td width="30%">' . $langs->trans("SavingAccounts") . '</td>'; print '<td width="20%">' . $langs->trans("Bank") . '</td>'; print '<td align="left">' . $langs->trans("Numero") . '</td>'; print '<td align="center" width="100">' . $langs->trans("TransactionsToConciliate") . '</td>'; print '<td align="center" width="70">' . $langs->trans("Status") . '</td>'; print '<td align="right" width="100">' . $langs->trans("BankBalance") . '</td>'; print "</tr>\n"; $total = 0; $found = 0; $var = true; foreach ($accounts as $key => $type) { if ($type == 0) { $found++; $acc = new Account($db); $acc->fetch($key); $var = !$var; $solde = $acc->solde(1); print "<tr " . $bc[$var] . ">"; print '<td width="30%">' . $acc->getNomUrl(1) . '</td>'; print '<td>' . $acc->bank . '</td>'; print '<td>' . $acc->number . '</td>'; print '<td align="center">'; if ($acc->rappro) { $result = $acc->load_board($user, $acc->id); print $acc->nbtodo; if ($acc->nbtodolate) { print ' (' . $acc->nbtodolate . img_warning($langs->trans("Late")) . ')'; } } else { print $langs->trans("FeatureDisabled");
dol_fiche_head($head, 'annual', $langs->trans("FinancialAccount"), 0, 'account'); $title = $langs->trans("FinancialAccount") . " : " . $acct->label; $link = $year_start ? "<a href='" . $_SERVER["PHP_SELF"] . "?account=" . $acct->id . "&year_start=" . ($year_start - 1) . "'>" . img_previous() . "</a> " . $langs->trans("Year") . " <a href='" . $_SERVER["PHP_SELF"] . "?account=" . $acct->id . "&year_start=" . ($year_start + 1) . "'>" . img_next() . "</a>" : ""; print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/compta/bank/index.php">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td width="25%">' . $langs->trans("Ref") . '</td>'; print '<td colspan="3">'; if ($_GET["account"]) { if (!preg_match('/,/', $id)) { print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref'); } else { $bankaccount = new Account($db); $listid = explode(',', $id); foreach ($listid as $key => $aId) { $bankaccount->fetch($aId); $bankaccount->label = $bankaccount->ref; print $bankaccount->getNomUrl(1); if ($key < count($listid) - 1) { print ', '; } } } } else { print $langs->trans("ALL"); } print '</td></tr>'; // Label print '<tr><td>' . $langs->trans("Label") . '</td>'; print '<td colspan="3">'; if (!empty($id)) {
/** * Add a payment of localtax * * @param User $user Object user that insert * @return int <0 if KO, rowid in localtax table if OK */ function addPayment($user) { global $conf, $langs; $this->db->begin(); // Check parameters $this->amount = price2num($this->amount); if (!$this->label) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } if ($this->amount <= 0) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -4; } if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); return -5; } if (!empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); return -5; } // Insertion dans table des paiement localtax $sql = "INSERT INTO " . MAIN_DB_PREFIX . "localtax (localtaxtype, datep, datev, amount"; if ($this->note) { $sql .= ", note"; } if ($this->label) { $sql .= ", label"; } $sql .= ", fk_user_creat, fk_bank"; $sql .= ") "; $sql .= " VALUES (" . $this->ltt . ", '" . $this->db->idate($this->datep) . "',"; $sql .= "'" . $this->db->idate($this->datev) . "'," . $this->amount; if ($this->note) { $sql .= ", '" . $this->db->escape($this->note) . "'"; } if ($this->label) { $sql .= ", '" . $this->db->escape($this->label) . "'"; } $sql .= ", '" . $user->id . "', NULL"; $sql .= ")"; dol_syslog(get_class($this) . "::addPayment", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "localtax"); // TODO devrait s'appeler paiementlocaltax if ($this->id > 0) { $ok = 1; if (!empty($conf->banque->enabled)) { // Insertion dans llx_bank require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $acc = new Account($this->db); $result = $acc->fetch($this->accountid); if ($result <= 0) { dol_print_error($this->db); } $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user); // Mise a jour fk_bank dans llx_localtax. On connait ainsi la ligne de localtax qui a g�n�r� l'�criture bancaire if ($bank_line_id > 0) { $this->update_fk_bank($bank_line_id); } else { $this->error = $acc->error; $ok = 0; } // Mise a jour liens $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT . '/compta/localtax/card.php?id=', "(VATPayment)", "payment_vat"); if ($result < 0) { $this->error = $acc->error; $ok = 0; } } if ($ok) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); return -3; } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } }
/** * Show miscellaneous information (payment mode, payment term, ...) * * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object * @return void */ function _tableau_info(&$pdf, $object, $posy, $outputlangs) { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); $posy = $pdf->GetY() + 4; } $posxval = 52; // Show payments conditions if ($object->cond_reglement_code || $object->cond_reglement) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions") . ':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement = str_replace('\\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); $posy = $pdf->GetY() + 3; } // Check a payment mode is defined /* Not used with orders if (empty($object->mode_reglement_code) && ! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetTextColor(200,0,0); $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); $pdf->SetTextColor(0,0,0); $posy=$pdf->GetY()+1; } */ /* TODO else if (! empty($object->availability_code)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetTextColor(200,0,0); $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0); $pdf->SetTextColor(0,0,0); $posy=$pdf->GetY()+1; }*/ // Show planed date of delivery if (!empty($object->date_livraison)) { $outputlangs->load("sendings"); $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("DateDeliveryPlanned") . ':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); $posy = $pdf->GetY() + 1; } elseif ($object->availability_code || $object->availability) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("AvailabilityPeriod") . ':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); $lib_availability = $outputlangs->transnoentities("AvailabilityType" . $object->availability_code) != 'AvailabilityType' . $object->availability_code ? $outputlangs->transnoentities("AvailabilityType" . $object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); $lib_availability = str_replace('\\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); $posy = $pdf->GetY() + 1; } // Show payment mode if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode") . ':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) != 'PaymentType' . $object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; } // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_CHQ_NUMBER); $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $posy = $pdf->GetY() + 2; } } } } // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { if (!empty($conf->global->FACTURE_RIB_NUMBER)) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_RIB_NUMBER); $curx = $this->marge_gauche; $cury = $posy; $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); $posy += 2; } } return $posy; }
$adherent->login = $objp->login; print "<tr>"; print '<td>' . $objp->_id . '</td>'; // Login print '<td>' . $objp->login . '</td>'; print '<td>' . $objp->Firstname . '</td>'; print '<td>' . $objp->Lastname . '</td>'; // Libelle print '<td>'; print dol_trunc($objp->note, 32); print '</td>'; // Banque if ($conf->banque->enabled) { if ($objp->fk_account) { $accountstatic->id = $objp->fk_account; $accountstatic->fetch($objp->fk_account); //$accountstatic->label=$objp->label; print '<td>' . $accountstatic->getNomUrl(1) . '</td>'; } else { print "<td>"; if ($allowinsertbankafter && $objp->cotisation) { print '<input type="hidden" name="action" value="2bank">'; print '<input type="hidden" name="rowid" value="' . $objp->crowid . '">'; $form = new Form($db); $form->select_comptes('', 'accountid', 0, '', 1); print '<br>'; $form->select_types_paiements('', 'paymenttypeid'); print '<input name="num_chq" type="text" class="flat" size="5">'; } else { print ' '; }
/** * Show miscellaneous information (payment mode, payment term, ...) * * @param PDF &$pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object * @return void */ function _tableau_info(&$pdf, $object, $posy, $outputlangs) { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 1); // If France, show VAT mention if not applicable if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); $posy = $pdf->GetY() + 4; } $posxval = 52; // Show payments conditions if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions") . ':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval - 6, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != 'PaymentCondition' . $object->cond_reglement_code ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement = str_replace('\\n', "\n", $lib_condition_paiement); $pdf->MultiCell(65, 4, $lib_condition_paiement, 0, 'L'); $posy = $pdf->GetY() + 3; } if ($object->type != 2) { // Check a payment mode is defined if (empty($object->mode_reglement_code) && !$conf->global->FACTURE_CHQ_NUMBER && !$conf->global->FACTURE_RIB_NUMBER) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetTextColor(200, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"), 0, 'L', 0); $pdf->SetTextColor(0, 0, 0); $posy = $pdf->GetY() + 1; } // Show payment mode if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode") . ':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) != 'PaymentType' . $object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); $posy = $pdf->GetY() + 2; } // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_CHQ_NUMBER); $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $posy = $pdf->GetY() + 2; } } } } // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) { if (empty($object->fk_bank) || $object->fk_bank == '') { $bankid = $conf->global->FACTURE_RIB_NUMBER; } else { $bankid = $object->fk_bank; } $account = new Account($this->db); $account->fetch($bankid); $curx = $this->marge_gauche; $cury = $posy; $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); $posy += 2; } } // Mostrar aviso pago con pagaré // $pdf->SetXY($this->marge_gauche, $posy); // $pdf->SetFont('','B', $default_font_size - 2); // $pdf->SetTextColor(0,0,60); // $pdf->MultiCell(100, 3, "Aceptamos pago mediante Pagaré a la orden.", '', 'L'); // Mostrar de nuevo la fecha de vencimiento $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance") . " : " . dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'L'); } return $posy; }
*/ if ($action == "set") { $db->begin(); for ($i = 0; $i < 2; $i++) { $res = dolibarr_set_const($db, GETPOST("nom{$i}", 'alpha'), GETPOST("value{$i}", 'alpha'), 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } } $res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } $id = GETPOST('PRELEVEMENT_ID_BANKACCOUNT', 'int'); $account = new Account($db); if ($account->fetch($id) > 0) { $res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } $res = dolibarr_set_const($db, "PRELEVEMENT_NUMERO_COMPTE", $account->number, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++;
} else { dol_print_error($db); } /* * View */ $form = new Form($db); llxHeader(); $societestatic = new Societe($db); $chargestatic = new ChargeSociales($db); $memberstatic = new Adherent($db); $paymentstatic = new Paiement($db); $paymentsupplierstatic = new PaiementFourn($db); $paymentvatstatic = new TVA($db); $acct = new Account($db); $acct->fetch($id); $now = dol_now(); $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " WHERE rappro=0 AND fk_account=" . $acct->id; $sql .= " ORDER BY dateo ASC"; $sql .= " LIMIT 1000"; // Limit to avoid page overload /// ajax adjust value date print ' <script type="text/javascript"> $(function() { $("a.ajax").each(function(){ var current = $(this); current.click(function() {
/** * Add record into bank for payment with links between this bank record and invoices of payment. * All payment properties must have been set first like after a call to create(). * * @param User $user Object of user making payment * @param string $mode 'payment_donation' * @param string $label Label to use in bank record * @param int $accountid Id of bank account to do link with * @param string $emetteur_nom Name of transmitter * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; $error = 0; if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); $total = $this->total; if ($mode == 'payment_donation') { $amount = $total; } // Insert payment into llx_bank $bank_line_id = $acc->addline($this->datepaid, $this->paymenttype, $label, $amount, $this->num_payment, '', $user, $emetteur_nom, $emetteur_banque); // Update fk_bank in llx_paiement. // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; dol_print_error($this->db); } // Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction $url = ''; if ($mode == 'payment_donation') { $url = DOL_URL_ROOT . '/don/payment/card.php?rowid='; } if ($url) { $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; dol_print_error($this->db); } } } else { $this->error = $acc->error; $error++; } } if (!$error) { return 1; } else { return -1; } }
} $outputlangs = $langs; if (!empty($newlangid)) { if ($outputlangs->defaultlang != $newlangid) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlangid); } } $outputlangs->load("main"); $outputlangs->load("bills"); $outputlangs->load("companies"); $outputlangs->load("banks"); $outputlangs->load("members"); $outputlangs->load("compta"); $acct = new Account($db); $result = $acct->fetch('', $bankref); if ($result <= 0) { print "Failed to find bank account with ref " . $bankref . ".\n"; exit(-1); } else { print "Export for bank account " . $acct->ref . " (" . $acct->label . ").\n"; } // Creation de la classe d'export du model ExportXXX $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; $file = "export_" . $model . ".modules.php"; $classname = "Export" . $model; if (!dol_is_file($dir . $file)) { print "No driver to export with format " . $model . "\n"; exit(-1); } require_once $dir . $file;
* View */ llxHeader(); $form = new Form($db); $societestatic = new Societe($db); $chargestatic = new ChargeSociales($db); $memberstatic = new Adherent($db); $paymentstatic = new Paiement($db); $paymentsupplierstatic = new PaiementFourn($db); $paymentvatstatic = new TVA($db); $bankstatic = new Account($db); $banklinestatic = new AccountLine($db); // Load account $acct = new Account($db); if ($id > 0 || !empty($ref)) { $acct->fetch($id, $ref); } if (empty($num)) { /* * Vue liste tous releves confondus */ $sql = "SELECT DISTINCT(b.num_releve) as numr"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " WHERE b.fk_account = " . $acct->id; $sql .= " ORDER BY numr DESC"; $sql .= $db->plimit($conf->liste_limit + 1, $offset); $result = $db->query($sql); if ($result) { $var = True; $numrows = $db->num_rows($result); $i = 0;
$label = $_POST["label"]; $cat1 = $_POST["cat1"]; if (!$dateop) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); } if (!$operation) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); } if (!$amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); } if (!$error) { $object->fetch($id); $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); if ($insertid > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id . "&action=addline"); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } else { $action = 'addline'; } } if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) { $accline = new AccountLine($db); $result = $accline->fetch(GETPOST("rowid"));
} if (!$error && $action == 'cotisation') { $db->begin(); // Create subscription $crowid = $object->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); if ($crowid <= 0) { $error++; $errmsg = $object->error; setEventMessages($object->error, $object->errors, 'errors'); } if (!$error) { // Insert into bank account directlty (if option choosed for) + link to llx_cotisation if option is 'bankdirect' if ($option == 'bankdirect' && $accountid) { require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $acct = new Account($db); $result = $acct->fetch($accountid); $dateop = $paymentdate; $insertid = $acct->addline($dateop, $operation, $label, $cotisation, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); if ($insertid > 0) { $inserturlid = $acct->add_url_line($insertid, $object->id, DOL_URL_ROOT . '/adherents/card.php?rowid=', $object->getFullname($langs), 'member'); if ($inserturlid > 0) { // Met a jour la table cotisation $sql = "UPDATE " . MAIN_DB_PREFIX . "cotisation SET fk_bank=" . $insertid; $sql .= " WHERE rowid=" . $crowid; dol_syslog("card_subscriptions::cotisation", LOG_DEBUG); $resql = $db->query($sql); if (!$resql) { $error++; $errmsg = $db->lasterror(); } } else {
$companyLink = $company->getNomUrl(1); } if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) { $bankcash = new Account($db); $bankcash->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]); $bankcash->label = $bankcash->ref; $bankcashLink = $bankcash->getNomUrl(1); } if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) { $bankcb = new Account($db); $bankcb->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]); $bankcbLink = $bankcb->getNomUrl(1); } if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) { $bankcheque = new Account($db); $bankcheque->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]); $bankchequeLink = $bankcheque->getNomUrl(1); } if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled)) { $warehouse = new Entrepot($db); $warehouse->fetch($_SESSION["CASHDESK_ID_WAREHOUSE"]); $warehouseLink = $warehouse->getNomUrl(1); } $langs->load("cashdesk"); $langs->load("main"); print '<div class="menu_bloc">'; print '<ul class="menu">'; // Link to new sell print '<li class="menu_choix1"><a href="affIndex.php?menu=facturation&id=NOUV"><span>' . $langs->trans("NewSell") . '</span></a></li>'; // Open new tab on backoffice (this is not a disconnect from POS) print '<li class="menu_choix2"><a href=".." target="backoffice"><span>' . $langs->trans("BackOffice") . '</span></a></li>';
/** * Add record into bank for payment with links between this bank record and invoices of payment. * All payment properties must have been set first like after a call to create(). * * @param User $user Object of user making payment * @param string $mode 'payment_loan' * @param string $label Label to use in bank record * @param int $accountid Id of bank account to do link with * @param string $emetteur_nom Name of transmitter * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; $error = 0; if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); $total = $this->total; if ($mode == 'payment_loan') { $total = -$total; } // Insert payment into llx_bank $bank_line_id = $acc->addline($this->datepaid, $this->paymenttype, $label, $total, $this->num_payment, '', $user, $emetteur_nom, $emetteur_banque); // Update fk_bank into llx_paiement. // We know the payment who generated the account write if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; dol_print_error($this->db); } // Add link 'payment_loan' in bank_url between payment and bank transaction $url = ''; if ($mode == 'payment_loan') { $url = DOL_URL_ROOT . '/loan/payment/card.php?id='; } if ($url) { $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode); if ($result <= 0) { $error++; dol_print_error($this->db); } } // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) //$linkaddedforthirdparty=array(); if ($mode == 'payment_loan') { $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT . '/loan/card.php?id=', $this->label ? $this->label : '', 'loan'); if ($result <= 0) { dol_print_error($this->db); } } } else { $this->error = $acc->error; $error++; } } if (!$error) { return 1; } else { return -1; } }
$page = GETPOST("page", 'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { $sortorder = "ASC"; } if (!$sortfield) { $sortfield = "name"; } $object = new Account($db); if ($id) { $object->fetch($id); } /* * Actions */ // Envoi fichier if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->fetch($id)) { $upload_dir = $conf->bank->dir_output . "/" . $object->ref; if (dol_mkdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
/** * Add record into bank for payment with links between this bank record and invoices of payment. * All payment properties must have been set first like after a call to create(). * * @param User $user Object of user making payment * @param string $mode 'payment_expensereport' * @param string $label Label to use in bank record * @param int $accountid Id of bank account to do link with * @param string $emetteur_nom Name of transmitter * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $langs, $conf; $error = 0; if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); $total = $this->total; if ($mode == 'payment_expensereport') { $amount = $total; } // Insert payment into llx_bank $bank_line_id = $acc->addline($this->datepaid, $this->fk_typepayment, $label, -$amount, $this->num_payment, '', $user, $emetteur_nom, $emetteur_banque); // Update fk_bank in llx_paiement. // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; dol_print_error($this->db); } // Add link 'payment', 'payment_supplier', 'payment_expensereport' in bank_url between payment and bank transaction $url = ''; if ($mode == 'payment_expensereport') { $url = DOL_URL_ROOT . '/expensereport/payment/card.php?rowid='; } if ($url) { $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; dol_print_error($this->db); } } // Add link 'user' in bank_url between user and bank transaction if (!$error) { foreach ($this->amounts as $key => $value) { if ($mode == 'payment_expensereport') { $euser = new User($this->db); $euser->fetch($key); $result = $acc->add_url_line($bank_line_id, $euser->id, DOL_URL_ROOT . '/user/card.php?id=', $euser->getFullName($langs), 'user'); if ($result <= 0) { $this->error = $this->db->lasterror(); dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->error); $error++; } } } } } else { $this->error = $acc->error; $error++; } } if (!$error) { return 1; } else { return -1; } }