예제 #1
0
    } else {
        $error++;
        $langs->load("errors");
        $mesg = '<div class="error">' . $langs->trans("ErrorPleaseTypeBankTransactionReportName") . '</div>';
    }
    if (!$error) {
        header('Location: ' . DOL_URL_ROOT . '/compta/bank/rappro.php?account=' . $id);
        // To avoid to submit twice and allow back
        exit;
    }
}
/*
 * Action suppression ecriture
 */
if ($action == 'del') {
    $bankline = new AccountLine($db);
    $bankline->fetch($_GET["rowid"]);
    $result = $bankline->delete($user);
    if ($result < 0) {
        dol_print_error($db, $bankline->error);
    }
}
// Load bank groups
$sql = "SELECT rowid, label FROM " . MAIN_DB_PREFIX . "bank_categ ORDER BY label";
$resql = $db->query($sql);
$options = "";
if ($resql) {
    $var = True;
    $num = $db->num_rows($resql);
    if ($num > 0) {
        $options .= '<option value="0"' . (GETPOST('cat') ? '' : ' selected="true"') . '>&nbsp;</option>';
예제 #2
0
 /**
  *	Supprime un paiement ainsi que les lignes qu'il a genere dans comptes
  *	Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
  *	Si le paiement porte sur au moins une facture a "payee", on refuse
  *
  *	@param		int		$notrigger		No trigger
  *	@return     int     <0 si ko, >0 si ok
  */
 function delete($notrigger = 0)
 {
     global $conf, $user, $langs;
     $bank_line_id = $this->bank_line;
     $this->db->begin();
     // Verifier si paiement porte pas sur une facture a l'etat payee
     // Si c'est le cas, on refuse la suppression
     $billsarray = $this->getBillsArray('paye=1');
     if (is_array($billsarray)) {
         if (count($billsarray)) {
             $this->error = "ErrorCantDeletePaymentSharedWithPayedInvoice";
             $this->db->rollback();
             return -1;
         }
     } else {
         $this->db->rollback();
         return -2;
     }
     // Verifier si paiement ne porte pas sur ecriture bancaire rapprochee
     // Si c'est le cas, on refuse le delete
     if ($bank_line_id) {
         $accline = new AccountLine($this->db, $bank_line_id);
         $accline->fetch($bank_line_id);
         if ($accline->rappro) {
             $this->error = "ErrorCantDeletePaymentReconciliated";
             $this->db->rollback();
             return -3;
         }
     }
     // Efface la ligne de paiement (dans paiement_facture et paiement)
     $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'paiementfourn_facturefourn';
     $sql .= ' WHERE fk_paiementfourn = ' . $this->id;
     $resql = $this->db->query($sql);
     if ($resql) {
         $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'paiementfourn';
         $sql .= ' WHERE rowid = ' . $this->id;
         $result = $this->db->query($sql);
         if (!$result) {
             $this->error = $this->db->error();
             $this->db->rollback();
             return -3;
         }
         // Supprimer l'ecriture bancaire si paiement lie a ecriture
         if ($bank_line_id) {
             $accline = new AccountLine($this->db);
             $result = $accline->fetch($bank_line_id);
             if ($result > 0) {
                 $result = $accline->delete();
             }
             if ($result < 0) {
                 $this->error = $accline->error;
                 $this->db->rollback();
                 return -4;
             }
         }
         if (!$notrigger) {
             // Appel des triggers
             $result = $this->call_trigger('PAYMENT_SUPPLIER_DELETE', $user);
             if ($result < 0) {
                 $this->db->rollback();
                 return -1;
             }
             // Fin appel triggers
         }
         $this->db->commit();
         return 1;
     } else {
         $this->error = $this->db->error;
         $this->db->rollback();
         return -5;
     }
 }
예제 #3
0
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype);
if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) {
    accessforbidden();
}
/*
 * Actions
 */
if ($user->rights->banque->consolidate && $action == 'dvnext') {
    $al = new AccountLine($db);
    $al->datev_next($_GET["rowid"]);
}
if ($user->rights->banque->consolidate && $action == 'dvprev') {
    $al = new AccountLine($db);
    $al->datev_previous($_GET["rowid"]);
}
if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) {
    $sql = "DELETE FROM " . MAIN_DB_PREFIX . "bank_class WHERE lineid = " . $rowid . " AND fk_categ = " . GETPOST("cat1");
    if (!$db->query($sql)) {
        dol_print_error($db);
    }
}
if ($user->rights->banque->modifier && $action == 'class') {
    $sql = "DELETE FROM " . MAIN_DB_PREFIX . "bank_class WHERE lineid = " . $rowid . " AND fk_categ = " . $_POST["cat1"];
    if (!$db->query($sql)) {
        dol_print_error($db);
    }
    $sql = "INSERT INTO " . MAIN_DB_PREFIX . "bank_class (lineid, fk_categ) VALUES (" . $rowid . ", " . $_POST["cat1"] . ")";
    if (!$db->query($sql)) {
예제 #4
0
	/**
	 *      Supprime un paiement ainsi que les lignes qu'il a genere dans comptes
	 *      Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
	 *      Si le paiement porte sur au moins une facture a "payee", on refuse
	 *      @return     int     <0 si ko, >0 si ok
	 */
	function delete($notrigger=0)
	{
		global $conf, $user, $langs;

		$error=0;

		$bank_line_id = $this->bank_line;

		$this->db->begin();

		// Verifier si paiement porte pas sur une facture classee
		// Si c'est le cas, on refuse la suppression
		$billsarray=$this->getBillsArray('fk_statut > 1');
		if (is_array($billsarray))
		{
			if (sizeof($billsarray))
			{
				$this->error="ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
				$this->db->rollback();
				return -1;
			}
		}
		else
		{
			$this->db->rollback();
			return -2;
		}

		// Delete bank urls. If payment if on a conciliated line, return error.
		if ($bank_line_id)
		{
			$accline = new AccountLine($this->db);
			$accline->fetch($bank_line_id);
            $result=$accline->delete_urls($user);
            if ($result < 0)
            {
                $this->error=$accline->error;
				$this->db->rollback();
				return -3;
            }
		}

		// Delete payment (into paiement_facture and paiement)
		$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement_facture';
		$sql.= ' WHERE fk_paiement = '.$this->id;
		$result = $this->db->query($sql);
		if ($result)
		{
			$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement';
			$sql.= ' WHERE rowid = '.$this->id;
			$result = $this->db->query($sql);
			if (! $result)
			{
				$this->error=$this->db->lasterror();
				$this->db->rollback();
				return -3;
			}

			// Supprimer l'ecriture bancaire si paiement lie a ecriture
			if ($bank_line_id)
			{
				$accline = new AccountLine($this->db);
				$accline->fetch($bank_line_id);
				$result=$accline->delete();
				if ($result < 0)
				{
					$this->error=$accline->error;
					$this->db->rollback();
					return -4;
				}
			}

			if (! $notrigger)
			{
				// Appel des triggers
				include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
				$interface=new Interfaces($this->db);
				$result=$interface->run_triggers('PAYMENT_DELETE',$this,$user,$langs,$conf);
				if ($result < 0) { $error++; $this->errors=$interface->errors; }
				// Fin appel triggers
			}

			$this->db->commit();
			return 1;
		}
		else
		{
			$this->error=$this->db->error;
			$this->db->rollback();
			return -5;
		}
	}
예제 #5
0
파일: card.php 프로젝트: Samara94/dolibarr
 print '<td width="25%">' . $langs->trans("Ref") . '</td><td colspan="3">';
 print $vatpayment->ref;
 print '</td></tr>';
 // Label
 print '<tr><td>' . $langs->trans("Label") . '</td><td>' . $vatpayment->label . '</td></tr>';
 print "<tr>";
 print '<td>' . $langs->trans("DatePayment") . '</td><td colspan="3">';
 print dol_print_date($vatpayment->datep, 'day');
 print '</td></tr>';
 print '<tr><td>' . $langs->trans("DateValue") . '</td><td colspan="3">';
 print dol_print_date($vatpayment->datev, 'day');
 print '</td></tr>';
 print '<tr><td>' . $langs->trans("Amount") . '</td><td colspan="3">' . price($vatpayment->amount) . '</td></tr>';
 if (!empty($conf->banque->enabled)) {
     if ($vatpayment->fk_account > 0) {
         $bankline = new AccountLine($db);
         $bankline->fetch($vatpayment->fk_bank);
         print '<tr>';
         print '<td>' . $langs->trans('BankTransactionLine') . '</td>';
         print '<td colspan="3">';
         print $bankline->getNomUrl(1, 0, 'showall');
         print '</td>';
         print '</tr>';
     }
 }
 // Other attributes
 $parameters = array('colspan' => ' colspan="3"');
 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $vatpayment, $action);
 // Note that $action and $object may have been modified by hook
 print '</table>';
 print '</div>';
예제 #6
0
            $i++;
        }
        print "</table>";
        print '<div class="tabsAction">';
        if ($user->rights->banque->cheque) {
            print '<input type="submit" class="button" value="' . $langs->trans('NewCheckDepositOn', $account_label) . '">';
        } else {
            print '<a class="butActionRefused" href="#" title="' . $langs->trans("NotEnoughPermissions") . '">' . $langs->trans('NewCheckDepositOn', $account_label) . '</a>';
        }
        print '</div><br>';
        print '</form>';
    }
} else {
    $linkback = '<a href="' . $_SERVER["PHP_SELF"] . '?leftmenu=customers_bills_checks&action=new">' . $langs->trans("BackToList") . '</a>';
    $paymentstatic = new Paiement($db);
    $accountlinestatic = new AccountLine($db);
    $accountstatic = new Account($db);
    $accountstatic->id = $object->account_id;
    $accountstatic->label = $object->account_label;
    print '<table class="border" width="100%">';
    print '<tr><td width=20%>';
    print '<table class="nobordernopadding" width="100%"><tr><td>';
    print $langs->trans('Ref');
    print '</td>';
    if ($action != 'editref') {
        print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editref&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetRef'), 1) . '</a></td>';
    }
    print '</tr></table>';
    print '</td><td colspan="2">';
    if ($action == 'editref') {
        print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">';
 /**
  *	Delete a subscription
  *
  *	@param	User	$user		User that delete
  *	@return	int					<0 if KO, 0 if not found, >0 if OK
  */
 function delete($user)
 {
     // It subscription is linked to a bank transaction, we get it
     if ($this->fk_bank) {
         require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
         $accountline = new AccountLine($this->db);
         $result = $accountline->fetch($this->fk_bank);
     }
     $this->db->begin();
     $sql = "DELETE FROM " . MAIN_DB_PREFIX . "cotisation WHERE rowid = " . $this->id;
     dol_syslog(get_class($this) . "::delete sql=" . $sql);
     $resql = $this->db->query($sql);
     if ($resql) {
         $num = $this->db->affected_rows($resql);
         if ($num) {
             require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
             $member = new Adherent($this->db);
             $result = $member->fetch($this->fk_adherent);
             $result = $member->update_end_date($user);
             if ($accountline->rowid > 0) {
                 $result = $accountline->delete($user);
                 // Return false if refused because line is conciliated
                 if ($result > 0) {
                     $this->db->commit();
                     return 1;
                 } else {
                     $this->error = $accountline->error;
                     $this->db->rollback();
                     return -1;
                 }
             } else {
                 $this->db->commit();
                 return 1;
             }
         } else {
             $this->db->commit();
             return 0;
         }
     } else {
         $this->error = $this->db->lasterror();
         $this->db->rollback();
         return -1;
     }
 }
예제 #8
0
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php");

$langs->load("banks");
$langs->load("companies");


/*
 * View
 */

llxHeader();

$line = new AccountLine($db);
$line->fetch($_GET["rowid"]);
$line->info($_GET["rowid"]);


$h=0;

$head[$h][0] = DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$_GET["rowid"];
$head[$h][1] = $langs->trans("Card");
$h++;

$head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$_GET["rowid"];
$head[$h][1] = $langs->trans("Info");
$hselected = $h;
$h++;
 /**
  *      Delete a social contribution
  *
  *      @param		User    $user   Object user making delete
  *      @return     		int 	<0 if KO, >0 if OK
  */
 function delete($user)
 {
     $error = 0;
     $this->db->begin();
     // Get bank transaction lines for this social contributions
     include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
     $account = new Account($this->db);
     $lines_url = $account->get_url('', $this->id, 'sc');
     // Delete bank urls
     foreach ($lines_url as $line_url) {
         if (!$error) {
             $accountline = new AccountLine($this->db);
             $accountline->fetch($line_url['fk_bank']);
             $result = $accountline->delete_urls($user);
             if ($result < 0) {
                 $error++;
             }
         }
     }
     // Delete payments
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "paiementcharge where fk_charge='" . $this->id . "'";
         dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if (!$resql) {
             $error++;
             $this->error = $this->db->lasterror();
         }
     }
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "chargesociales where rowid='" . $this->id . "'";
         dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if (!$resql) {
             $error++;
             $this->error = $this->db->lasterror();
         }
     }
     if (!$error) {
         $this->db->commit();
         return 1;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
예제 #10
0
파일: fiche.php 프로젝트: nrjacker4/crm-php
print $form->showrefnav($paiement, 'id', '', 1, 'rowid', 'id');
print '</td></tr>';
// Date
print '<tr><td valign="top" width="120">' . $langs->trans('Date') . '</td><td colspan="3">' . dol_print_date($paiement->datep, 'day') . '</td></tr>';
// Mode
print '<tr><td valign="top">' . $langs->trans('Mode') . '</td><td colspan="3">' . $langs->trans("PaymentType" . $paiement->type_code) . '</td></tr>';
// Numero
print '<tr><td valign="top">' . $langs->trans('Numero') . '</td><td colspan="3">' . $paiement->num_paiement . '</td></tr>';
// Montant
print '<tr><td valign="top">' . $langs->trans('Amount') . '</td><td colspan="3">' . price($paiement->amount) . '&nbsp;' . $langs->trans('Currency' . $conf->currency) . '</td></tr>';
// Note
print '<tr><td valign="top">' . $langs->trans('Note') . '</td><td colspan="3">' . nl2br($paiement->note) . '</td></tr>';
// Bank account
if ($conf->banque->enabled) {
    if ($paiement->bank_account) {
        $bankline = new AccountLine($db);
        $bankline->fetch($paiement->bank_line);
        print '<tr>';
        print '<td>' . $langs->trans('BankTransactionLine') . '</td>';
        print '<td colspan="3">';
        print $bankline->getNomUrl(1, 0, 'showall');
        print '</td>';
        print '</tr>';
    }
}
print '</table>';
/*
 * List of social contributions payed
 */
$disable_delete = 0;
$sql = 'SELECT f.rowid as scid, f.libelle, f.paye, f.amount as sc_amount, pf.amount, pc.libelle as sc_type';
}
//if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');    // Required to knwo date format for dol_print_date
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
$action = GETPOST('action');
/*
 * View
 */
// Ajout directives pour resoudre bug IE
//header('Cache-Control: Public, must-revalidate');
//header('Pragma: public');
//top_htmlhead("", "", 1);  // Replaced with top_httphead. An ajax page does not need html header.
top_httphead();
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext') {
    // Increase date
    $al = new AccountLine($db);
    $al->datev_next($_GET["rowid"]);
    $al->fetch($_GET["rowid"]);
    print '<span>' . dol_print_date($db->jdate($al->datev), "day") . '</span>';
    exit;
}
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') {
    // Decrease date
    $al = new AccountLine($db);
    $al->datev_previous($_GET["rowid"]);
    $al->fetch($_GET["rowid"]);
    print '<span>' . dol_print_date($db->jdate($al->datev), "day") . '</span>';
    exit;
}
예제 #12
0
 print '<td>' . $langs->trans("DateSubscription") . '</td><td class="valeur" colspan="3">' . dol_print_date($subscription->dateh, 'day') . '</td>';
 print '</tr>';
 // Date end subscription
 print '<tr>';
 print '<td>' . $langs->trans("DateEndSubscription") . '</td><td class="valeur" colspan="3">' . dol_print_date($subscription->datef, 'day') . '</td>';
 print '</tr>';
 // Amount
 print '<tr><td>' . $langs->trans("Amount") . '</td><td class="valeur" colspan="3">' . price($subscription->amount) . '</td></tr>';
 // Amount
 print '<tr><td>' . $langs->trans("Label") . '</td><td class="valeur" colspan="3">' . $subscription->note . '</td></tr>';
 // Bank line
 if (!empty($conf->banque->enabled)) {
     if ($conf->global->ADHERENT_BANK_USE || $subscription->fk_bank) {
         print '<tr><td>' . $langs->trans("BankTransactionLine") . '</td><td class="valeur" colspan="3">';
         if ($subscription->fk_bank) {
             $bankline = new AccountLine($db);
             $result = $bankline->fetch($subscription->fk_bank);
             print $bankline->getNomUrl(1, 0, 'showall');
         } else {
             print $langs->trans("NoneF");
         }
         print '</td></tr>';
     }
 }
 print "</table>\n";
 print '</form>';
 dol_fiche_end();
 /*
  * Barre d'actions
  *
  */
예제 #13
0
 /**
  *	Check return management
  *	Reopen linked invoices and create a new negative payment.
  *
  *	@param	int		$bank_id 		   Id of bank transaction line concerned
  *	@param	date	$rejection_date    Date to use on the negative payment
  * 	@return	int                        Id of negative payment line created 
  */
 function rejectCheck($bank_id, $rejection_date)
 {
     global $db, $user;
     $payment = new Paiement($db);
     $payment->fetch(0, 0, $bank_id);
     $bankline = new AccountLine($db);
     $bankline->fetch($bank_id);
     /* Conciliation is allowed because when check is returned, a new line is created onto bank transaction log.
     		if ($bankline->rappro)
     		{
                 $this->error='ActionRefusedLineAlreadyConciliated';
     		    return -1;
     		}*/
     $this->db->begin();
     // Not conciliated, we can delete it
     //$bankline->delete($user);    // We delete
     $bankaccount = $payment->fk_account;
     // Get invoices list to reopen them
     $sql = 'SELECT pf.fk_facture, pf.amount';
     $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf';
     $sql .= ' WHERE pf.fk_paiement = ' . $payment->id;
     $resql = $db->query($sql);
     if ($resql) {
         $rejectedPayment = new Paiement($db);
         $rejectedPayment->amounts = array();
         $rejectedPayment->datepaye = $rejection_date;
         $rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement');
         $rejectedPayment->num_paiement = $payment->numero;
         while ($obj = $db->fetch_object($resql)) {
             $invoice = new Facture($db);
             $invoice->fetch($obj->fk_facture);
             $invoice->set_unpaid($user);
             $rejectedPayment->amounts[$obj->fk_facture] = price2num($obj->amount) * -1;
         }
         $result = $rejectedPayment->create($user);
         if ($result > 0) {
             // We created a negative payment, we also add the line as bank transaction
             $result = $rejectedPayment->addPaymentToBank($user, 'payment', '(CheckRejected)', $bankaccount, '', '');
             if ($result > 0) {
                 $result = $payment->reject();
                 if ($result > 0) {
                     $this->db->commit();
                     return $rejectedPayment->id;
                 } else {
                     $this->db->rollback();
                     return -1;
                 }
             } else {
                 $this->error = $rejectedPayment->error;
                 $this->errors = $rejectedPayment->errors;
                 $this->db->rollback();
                 return -1;
             }
         } else {
             $this->error = $rejectedPayment->error;
             $this->errors = $rejectedPayment->errors;
             $this->db->rollback();
             return -1;
         }
     } else {
         $this->error = $this->db->lasterror();
         $this->db->rollback();
         return -1;
     }
 }
예제 #14
0
$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')
        {
            $ret=$html->form_confirm("ligne.php?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1);
            if ($ret == 'html') print '<br>';
        }

        print '<form name="update" method="post" action="ligne.php?rowid='.$rowid.'">';
        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
        print '<input type="hidden" name="action" value="update">';
예제 #15
0
 /**
  *      Supprime un paiement ainsi que les lignes qu'il a genere dans comptes
  *      Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
  *      Si le paiement porte sur au moins une facture a "payee", on refuse
  *
  *      @param	int		$notrigger		No trigger
  *      @return int     				<0 si ko, >0 si ok
  */
 function delete($notrigger = 0)
 {
     global $conf, $user, $langs;
     $error = 0;
     $bank_line_id = $this->bank_line;
     $this->db->begin();
     // Verifier si paiement porte pas sur une facture classee
     // Si c'est le cas, on refuse la suppression
     $billsarray = $this->getBillsArray('fk_statut > 1');
     if (is_array($billsarray)) {
         if (count($billsarray)) {
             $this->error = "ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
             $this->db->rollback();
             return -1;
         }
     } else {
         $this->db->rollback();
         return -2;
     }
     $accline = new AccountLine($this->db);
     // Delete bank urls. If payment is on a conciliated line, return error.
     if ($bank_line_id) {
         $result = $accline->fetch($bank_line_id);
         if ($result == 0) {
             $accline->rowid = $bank_line_id;
         }
         // If not found, we set artificially rowid to allow delete of llx_bank_url
         $result = $accline->delete_urls($user);
         if ($result < 0) {
             $this->error = $accline->error;
             $this->db->rollback();
             return -3;
         }
     }
     // Delete payment (into paiement_facture and paiement)
     $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'paiement_facture';
     $sql .= ' WHERE fk_paiement = ' . $this->id;
     dol_syslog($sql);
     $result = $this->db->query($sql);
     if ($result) {
         $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'paiement';
         $sql .= ' WHERE rowid = ' . $this->id;
         dol_syslog($sql);
         $result = $this->db->query($sql);
         if (!$result) {
             $this->error = $this->db->lasterror();
             $this->db->rollback();
             return -3;
         }
         // Supprimer l'ecriture bancaire si paiement lie a ecriture
         if ($bank_line_id) {
             $result = $accline->delete($user);
             if ($result < 0) {
                 $this->error = $accline->error;
                 $this->db->rollback();
                 return -4;
             }
         }
         if (!$notrigger) {
             // Appel des triggers
             $result = $this->call_trigger('PAYMENT_DELETE', $user);
             if ($result < 0) {
                 $this->db->rollback();
                 return -1;
             }
             // Fin appel triggers
         }
         $this->db->commit();
         return 1;
     } else {
         $this->error = $this->db->error;
         $this->db->rollback();
         return -5;
     }
 }
예제 #16
0
        $result=$bankline->update_conciliation($user,$_POST["cat"]);
        if ($result < 0) $mesg=$bankline->error;
    }
    else
    {
    	$langs->load("errors");
        $mesg='<div class="error">'.$langs->trans("ErrorPleaseTypeBankTransactionReportName").'</div>';
    }
}

/*
 * Action suppression ecriture
 */
if ($_GET["action"] == 'del')
{
	$accline=new AccountLine($db);
	$accline->fetch($_GET["rowid"]);
	$result=$accline->delete();
    if ($result < 0)
	{
        dol_print_error($db,$accline->error);
    }
}


// Charge categories
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label";
$resql = $db->query($sql);
$options="";
if ($resql) {
    $var=True;
예제 #17
0
파일: card.php 프로젝트: ADDAdev/Dolibarr
$labeltype = $langs->trans("PaymentType" . $object->type_code) != "PaymentType" . $object->type_code ? $langs->trans("PaymentType" . $object->type_code) : $object->type_libelle;
print '<tr><td valign="top">' . $langs->trans('PaymentMode') . '</td><td colspan="3">' . $labeltype . '</td></tr>';
// Payment numero
print '<tr><td valign="top">' . $form->editfieldkey("Numero", 'num_paiement', $object->numero, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer) . '</td><td colspan="3">';
print $form->editfieldval("Numero", 'num_paiement', $object->numero, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer, 'string', '', null, $langs->trans('PaymentNumberUpdateSucceeded'));
print '</td></tr>';
// Amount
print '<tr><td valign="top">' . $langs->trans('Amount') . '</td><td colspan="3">' . price($object->montant, '', $langs, 0, 0, -1, $conf->currency) . '</td></tr>';
// Note
print '<tr><td valign="top">' . $form->editfieldkey("Note", 'note', $object->note, $object, $user->rights->facture->paiement) . '</td><td colspan="3">';
print $form->editfieldval("Note", 'note', $object->note, $object, $user->rights->facture->paiement, 'textarea');
print '</td></tr>';
// Bank account
if (!empty($conf->banque->enabled)) {
    if ($object->bank_account) {
        $bankline = new AccountLine($db);
        $bankline->fetch($object->bank_line);
        print '<tr>';
        print '<td>' . $langs->trans('BankTransactionLine') . '</td>';
        print '<td colspan="3">';
        print $bankline->getNomUrl(1, 0, 'showconciliated');
        print '</td>';
        print '</tr>';
        print '<tr>';
        print '<td>' . $langs->trans('BankAccount') . '</td>';
        print '<td colspan="3">';
        $accountstatic = new Account($db);
        $accountstatic->id = $bankline->fk_account;
        $accountstatic->label = $bankline->bank_account_ref . ' - ' . $bankline->bank_account_label;
        print $accountstatic->getNomUrl(0);
        print '</td>';
 /**
  *  Delete object in database
  *
  *  @param	User	$user        	User that delete
  *  @param  int		$notrigger		0=launch triggers after, 1=disable triggers
  *  @return int						<0 if KO, >0 if OK
  */
 function delete($user, $notrigger = 0)
 {
     global $conf, $langs;
     $error = 0;
     dol_syslog(get_class($this) . "::delete");
     $this->db->begin();
     if ($this->bank_line > 0) {
         $accline = new AccountLine($this->db);
         $accline->fetch($this->bank_line);
         $result = $accline->delete();
         if ($result < 0) {
             $this->errors[] = $accline->error;
             $error++;
         }
     }
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "paiementcharge";
         $sql .= " WHERE rowid=" . $this->id;
         dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if (!$resql) {
             $error++;
             $this->errors[] = "Error " . $this->db->lasterror();
         }
     }
     if (!$error) {
         if (!$notrigger) {
             // Uncomment this and change MYOBJECT to your own tag if you
             // want this action call a trigger.
             //// Call triggers
             //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
             //$interface=new Interfaces($this->db);
             //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
             //if ($result < 0) { $error++; $this->errors=$interface->errors; }
             //// End call triggers
         }
     }
     // Commit or rollback
     if ($error) {
         foreach ($this->errors as $errmsg) {
             dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
             $this->error .= $this->error ? ', ' . $errmsg : $errmsg;
         }
         $this->db->rollback();
         return -1 * $error;
     } else {
         $this->db->commit();
         return 1;
     }
 }
예제 #19
0
 print dol_print_date($object->datesp, 'day');
 print '</td></tr>';
 print '<tr><td>' . $langs->trans("DateEndPeriod") . '</td><td colspan="3">';
 print dol_print_date($object->dateep, 'day');
 print '</td></tr>';
 print "<tr>";
 print '<td>' . $langs->trans("DatePayment") . '</td><td colspan="3">';
 print dol_print_date($object->datep, 'day');
 print '</td></tr>';
 print '<tr><td>' . $langs->trans("DateValue") . '</td><td colspan="3">';
 print dol_print_date($object->datev, 'day');
 print '</td></tr>';
 print '<tr><td>' . $langs->trans("Amount") . '</td><td colspan="3">' . price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency) . '</td></tr>';
 if (!empty($conf->banque->enabled)) {
     if ($object->fk_account > 0) {
         $bankline = new AccountLine($db);
         $bankline->fetch($object->fk_bank);
         print '<tr>';
         print '<td>' . $langs->trans('BankTransactionLine') . '</td>';
         print '<td colspan="3">';
         print $bankline->getNomUrl(1, 0, 'showall');
         print '</td>';
         print '</tr>';
     }
 }
 // Other attributes
 $parameters = array('colspan' => ' colspan="3"');
 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
 // Note that $action and $object may have been modified by hook
 print '</table>';
 dol_fiche_end();
예제 #20
0
 /**
  *	Supprime un paiement ainsi que les lignes qu'il a genere dans comptes
  *	Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse
  *	Si le paiement porte sur au moins une facture a "payee", on refuse
  *
  *	@param		int		$notrigger		No trigger
  *	@return     int     <0 si ko, >0 si ok
  */
 function delete($notrigger = 0)
 {
     $bank_line_id = $this->bank_line;
     $this->db->begin();
     // Verifier si paiement porte pas sur une facture a l'etat payee
     // Si c'est le cas, on refuse la suppression
     $billsarray = $this->getBillsArray('paye=1');
     if (is_array($billsarray)) {
         if (count($billsarray)) {
             $this->error = 'Can\'t delete a payment shared by at least one invoice with status payed';
             $this->db->rollback();
             return -1;
         }
     } else {
         $this->db->rollback();
         return -2;
     }
     // Verifier si paiement ne porte pas sur ecriture bancaire rapprochee
     // Si c'est le cas, on refuse le delete
     if ($bank_line_id) {
         $accline = new AccountLine($this->db, $bank_line_id);
         $accline->fetch($bank_line_id);
         if ($accline->rappro) {
             $this->error = 'Impossible de supprimer un paiement qui a genere une ecriture qui a ete rapprochee';
             $this->db->rollback();
             return -3;
         }
     }
     // Efface la ligne de paiement (dans paiement_facture et paiement)
     $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'paiementfourn_facturefourn';
     $sql .= ' WHERE fk_paiementfourn = ' . $this->id;
     dol_syslog("sql=" . $sql);
     $resql = $this->db->query($sql);
     if ($resql) {
         $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'paiementfourn';
         $sql .= ' WHERE rowid = ' . $this->id;
         dol_syslog("sql=" . $sql);
         $result = $this->db->query($sql);
         if (!$result) {
             $this->error = $this->db->error();
             $this->db->rollback();
             return -3;
         }
         // Supprimer l'ecriture bancaire si paiement lie a ecriture
         if ($bank_line_id) {
             $accline = new AccountLine($this->db);
             $accline->fetch($bank_line_id);
             $result = $accline->delete();
             if ($result < 0) {
                 $this->error = $accline->error;
                 $this->db->rollback();
                 return -4;
             }
         }
         $this->db->commit();
         return 1;
     } else {
         $this->error = $this->db->error;
         $this->db->rollback();
         return -5;
     }
 }
예제 #21
0
 * View
 */
llxHeader('', $langs->trans("FinancialAccount") . '-' . $langs->trans("Transactions"));
$societestatic = new Societe($db);
$userstatic = new User($db);
$chargestatic = new ChargeSociales($db);
$loanstatic = new Loan($db);
$memberstatic = new Adherent($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db);
$donstatic = new Don($db);
$expensereportstatic = new ExpenseReport($db);
$bankstatic = new Account($db);
$banklinestatic = new AccountLine($db);
$form = new Form($db);
if ($id > 0 || !empty($ref)) {
    if ($vline) {
        $viewline = $vline;
    } else {
        $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT) ? 20 : $conf->global->MAIN_SIZE_LISTE_LIMIT;
    }
    $result = $object->fetch($id, $ref);
    // Chargement des categories bancaires dans $options
    $nbcategories = 0;
    $sql = "SELECT rowid, label";
    $sql .= " FROM " . MAIN_DB_PREFIX . "bank_categ";
    $sql .= " WHERE entity = " . $conf->entity;
    $sql .= " ORDER BY label";
    $result = $db->query($sql);
예제 #22
0
$langs->load("bills");
// Security check
if (isset($_GET["account"]) || isset($_GET["ref"])) {
    $id = isset($_GET["account"]) ? $_GET["account"] : (isset($_GET["ref"]) ? $_GET["ref"] : '');
}
$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid';
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'banque', $id, 'bank_account', '', '', $fieldid);
if ($user->rights->banque->consolidate && $action == 'dvnext') {
    $al = new AccountLine($db);
    $al->datev_next($_GET["dvid"]);
}
if ($user->rights->banque->consolidate && $action == 'dvprev') {
    $al = new AccountLine($db);
    $al->datev_previous($_GET["dvid"]);
}
$sortfield = isset($_GET["sortfield"]) ? $_GET["sortfield"] : $_POST["sortfield"];
$sortorder = isset($_GET["sortorder"]) ? $_GET["sortorder"] : $_POST["sortorder"];
$page = isset($_GET["page"]) ? $_GET["page"] : $_POST["page"];
if ($page == -1) {
    $page = 0;
}
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "s.nom";
}
$offset = $conf->liste_limit * $page;