forked from Wavyzz/dolibarr
Uniformize code
This commit is contained in:
@@ -229,7 +229,7 @@ if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->rights->ban
|
|||||||
{
|
{
|
||||||
$reject_date = dol_mktime(0, 0, 0, GETPOST('rejectdate_month'), GETPOST('rejectdate_day'), GETPOST('rejectdate_year'));
|
$reject_date = dol_mktime(0, 0, 0, GETPOST('rejectdate_month'), GETPOST('rejectdate_day'), GETPOST('rejectdate_year'));
|
||||||
$rejected_check = GETPOST('bankid');
|
$rejected_check = GETPOST('bankid');
|
||||||
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$paiement_id = $object->reject_check($rejected_check, $reject_date);
|
$paiement_id = $object->reject_check($rejected_check, $reject_date);
|
||||||
if ($paiement_id > 0)
|
if ($paiement_id > 0)
|
||||||
@@ -353,7 +353,7 @@ else
|
|||||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1);
|
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirm check rejection
|
* Confirm check rejection
|
||||||
*/
|
*/
|
||||||
@@ -381,7 +381,7 @@ if ($action == 'new')
|
|||||||
print '<input type="hidden" name="action" value="new">';
|
print '<input type="hidden" name="action" value="new">';
|
||||||
|
|
||||||
dol_fiche_head();
|
dol_fiche_head();
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
//print '<tr><td width="30%">'.$langs->trans('Date').'</td><td width="70%">'.dol_print_date($now,'day').'</td></tr>';
|
//print '<tr><td width="30%">'.$langs->trans('Date').'</td><td width="70%">'.dol_print_date($now,'day').'</td></tr>';
|
||||||
// Filter
|
// Filter
|
||||||
@@ -392,9 +392,9 @@ if ($action == 'new')
|
|||||||
$form->select_comptes($filteraccountid,'accountid',0,'courant <> 2',1);
|
$form->select_comptes($filteraccountid,'accountid',0,'courant <> 2',1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
print '<div class="center">';
|
print '<div class="center">';
|
||||||
print '<input type="submit" class="button" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
|
print '<input type="submit" class="button" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
|
||||||
if ($filterdate || $filteraccountid > 0)
|
if ($filterdate || $filteraccountid > 0)
|
||||||
@@ -655,8 +655,7 @@ else
|
|||||||
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"b.amount", "",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"b.amount", "",$param,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("LineRecord"),$_SERVER["PHP_SELF"],"b.rowid", "",$param,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("LineRecord"),$_SERVER["PHP_SELF"],"b.rowid", "",$param,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Payment"),$_SERVER["PHP_SELF"],"p.rowid", "",$param,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Payment"),$_SERVER["PHP_SELF"],"p.rowid", "",$param,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre('');
|
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i=1;
|
$i=1;
|
||||||
$var=false;
|
$var=false;
|
||||||
@@ -699,17 +698,11 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
if ($object->statut == 0)
|
if ($object->statut == 0)
|
||||||
{
|
{
|
||||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&lineid='.$objp->rowid.'">'.img_delete().'</a></td>';
|
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&lineid='.$objp->rowid.'">'.img_delete().'</a>';
|
||||||
|
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reject_check&lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"),'disable').'</a></td>';
|
||||||
}
|
}
|
||||||
else
|
else if($objp->statut == 2) {
|
||||||
{
|
print '<td align="right">'.img_picto($langs->trans('CheckRejected'),'statut8').'</a></td>';
|
||||||
if($objp->statut == 0)
|
|
||||||
{
|
|
||||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reject_check&lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"),'disable').'</a></td>';
|
|
||||||
}
|
|
||||||
else if($objp->statut == 2) {
|
|
||||||
print '<td align="right">'.img_picto($langs->trans('CheckRejected'),'statut8').'</a></td>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|||||||
@@ -659,7 +659,7 @@ class RemiseCheque extends CommonObject
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check rejection management
|
* Check rejection management
|
||||||
* Reopen linked invoices and saves a new negative payment
|
* Reopen linked invoices and saves a new negative payment
|
||||||
@@ -671,34 +671,35 @@ class RemiseCheque extends CommonObject
|
|||||||
function reject_check($bank_id, $rejection_date)
|
function reject_check($bank_id, $rejection_date)
|
||||||
{
|
{
|
||||||
global $db, $user;
|
global $db, $user;
|
||||||
|
|
||||||
$payment = new Paiement($db);
|
$payment = new Paiement($db);
|
||||||
$payment->fetch(0,$bank_id);
|
$payment->fetch(0,0,$bank_id);
|
||||||
|
|
||||||
$bankaccount = $payment->fk_account;
|
$bankaccount = $payment->fk_account;
|
||||||
|
|
||||||
// Get invoice list to reopen them
|
// Get invoice list to reopen them
|
||||||
$sql = 'SELECT pf.fk_facture, pf.amount';
|
$sql = 'SELECT pf.fk_facture, pf.amount';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
|
||||||
$sql.= ' WHERE pf.fk_paiement = '.$payment->id;
|
$sql.= ' WHERE pf.fk_paiement = '.$payment->id;
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$rejectedPayment = new Paiement($db);
|
$rejectedPayment = new Paiement($db);
|
||||||
$rejectedPayment->amounts = array();
|
$rejectedPayment->amounts = array();
|
||||||
$rejectedPayment->datepaye = $rejection_date;
|
$rejectedPayment->datepaye = $rejection_date;
|
||||||
$rejectedPayment->paiementid = 7; // type of payment: check
|
$rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement');
|
||||||
$rejectedPayment->num_paiement = $payment->numero;
|
$rejectedPayment->num_paiement = $payment->numero;
|
||||||
|
|
||||||
while($obj = $db->fetch_object($resql)) {
|
while($obj = $db->fetch_object($resql))
|
||||||
|
{
|
||||||
$invoice = new Facture($db);
|
$invoice = new Facture($db);
|
||||||
$invoice->fetch($obj->fk_facture);
|
$invoice->fetch($obj->fk_facture);
|
||||||
$invoice->set_unpaid($user);
|
$invoice->set_unpaid($user);
|
||||||
|
|
||||||
$rejectedPayment->amounts[$obj->fk_facture] = price2num($obj->amount) * -1;
|
$rejectedPayment->amounts[$obj->fk_facture] = price2num($obj->amount) * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rejectedPayment->create($user) > 0)
|
if ($rejectedPayment->create($user) > 0)
|
||||||
{
|
{
|
||||||
$result=$rejectedPayment->addPaymentToBank($user,'payment','(CheckRejected)',$bankaccount,'','');
|
$result=$rejectedPayment->addPaymentToBank($user,'payment','(CheckRejected)',$bankaccount,'','');
|
||||||
@@ -723,7 +724,7 @@ class RemiseCheque extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Charge les proprietes ref_previous et ref_next
|
* Charge les proprietes ref_previous et ref_next
|
||||||
*
|
*
|
||||||
@@ -813,7 +814,7 @@ class RemiseCheque extends CommonObject
|
|||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
|
||||||
$sql.= " SET number = '".$number."'" ;
|
$sql.= " SET number = '".$number."'" ;
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog("RemiseCheque::set_number", LOG_DEBUG);
|
dol_syslog("RemiseCheque::set_number", LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@@ -79,10 +79,11 @@ class Paiement extends CommonObject
|
|||||||
* Load payment from database
|
* Load payment from database
|
||||||
*
|
*
|
||||||
* @param int $id Id of payment to get
|
* @param int $id Id of payment to get
|
||||||
|
* @param string $ref Ref of payment to get (currently ref = id but this may change in future)
|
||||||
* @param int $fk_bank Id of bank line associated to payment
|
* @param int $fk_bank Id of bank line associated to payment
|
||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch($id, $fk_bank='')
|
function fetch($id, $ref='', $fk_bank='')
|
||||||
{
|
{
|
||||||
$sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,';
|
$sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,';
|
||||||
$sql.= ' c.code as type_code, c.libelle as type_libelle,';
|
$sql.= ' c.code as type_code, c.libelle as type_libelle,';
|
||||||
@@ -91,10 +92,12 @@ class Paiement extends CommonObject
|
|||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid ';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid ';
|
||||||
$sql.= ' WHERE p.fk_paiement = c.id';
|
$sql.= ' WHERE p.fk_paiement = c.id';
|
||||||
if ($fk_bank)
|
if ($id > 0)
|
||||||
$sql.= ' AND p.fk_bank = '.$fk_bank;
|
|
||||||
else
|
|
||||||
$sql.= ' AND p.rowid = '.$id;
|
$sql.= ' AND p.rowid = '.$id;
|
||||||
|
else if ($ref)
|
||||||
|
$sql.= ' AND p.rowid = '.$ref;
|
||||||
|
else if ($fk_bank)
|
||||||
|
$sql.= ' AND p.fk_bank = '.$fk_bank;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@@ -670,7 +673,7 @@ class Paiement extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reject payment
|
* Reject payment
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user