Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2018-09-23 15:58:43 +02:00
commit 33f9600c9c
2 changed files with 63 additions and 71 deletions

View File

@ -60,7 +60,8 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('bankcard','globalcard'));
/* /*
* Actions * Actions

View File

@ -49,6 +49,9 @@ $result=restrictedArea($user,'banque',$id,'bank_account&bank_account','','',$fie
$vline=isset($_GET["vline"])?$_GET["vline"]:$_POST["vline"]; $vline=isset($_GET["vline"])?$_GET["vline"]:$_POST["vline"];
$page=isset($_GET["page"])?$_GET["page"]:0; $page=isset($_GET["page"])?$_GET["page"]:0;
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('banktreso','globalcard'));
/* /*
* View * View
*/ */
@ -130,6 +133,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
// Remainder to pay in future // Remainder to pay in future
$sqls = array();
// Customer invoices // Customer invoices
$sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,"; $sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,";
@ -140,77 +144,53 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid
$sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice
$sql.= " ORDER BY dlr ASC"; $sql.= " ORDER BY dlr ASC";
$sqls[] = $sql;
// Supplier invoices // Supplier invoices
$sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; $sql = " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,";
$sql2.= " s.rowid as socid, s.nom as name, s.fournisseur"; $sql.= " s.rowid as socid, s.nom as name, s.fournisseur";
$sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid";
$sql2.= " WHERE ff.entity = ".$conf->entity; $sql.= " WHERE ff.entity = ".$conf->entity;
$sql2.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid $sql.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid
$sql2.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice
$sql2.= " ORDER BY dlr ASC"; $sql.= " ORDER BY dlr ASC";
$sqls[] = $sql;
// Social contributions // Social contributions
$sql3= " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; $sql = " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr";
$sql3.= ", cs.fk_account"; $sql.= ", cs.fk_account";
$sql3.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
$sql3.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id";
$sql3.= " WHERE cs.entity = ".$conf->entity; $sql.= " WHERE cs.entity = ".$conf->entity;
$sql3.= " AND cs.paye = 0"; // Not paid $sql.= " AND cs.paye = 0"; // Not paid
$sql3.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution
$sql3.= " ORDER BY dlr ASC"; $sql.= " ORDER BY dlr ASC";
$sqls[] = $sql;
// others sql
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if(empty($reshook) and isset($hookmanager->resArray['sql'])){
$sqls[] = $hookmanager->resArray['sql'];
}
$error=0; $error=0;
$tab_sqlobjOrder=array(); $tab_sqlobjOrder=array();
$tab_sqlobj=array(); $tab_sqlobj=array();
// List customer invoices foreach($sqls as $sql){
$result = $db->query($sql); $resql = $db->query($sql);
if ($result) if($resql){
{ while($sqlobj = $db->fetch_object($resql)){
$num = $db->num_rows($result);
for ($i = 0;$i < $num;$i++)
{
$sqlobj = $db->fetch_object($result);
$tab_sqlobj[] = $sqlobj; $tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr);
} }
$db->free($result); $db->free($resql);
}else{
$error++;
} }
else $error++;
// List supplier invoices
$result2=$db->query($sql2);
if ($result2)
{
$num = $db->num_rows($result2);
for ($i = 0;$i < $num;$i++)
{
$sqlobj = $db->fetch_object($result2);
$tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr);
} }
$db->free($result2);
}
else $error++;
// List social contributions
$result3=$db->query($sql3);
if ($result3)
{
$num = $db->num_rows($result3);
for ($i = 0;$i < $num;$i++)
{
$sqlobj = $db->fetch_object($result3);
$tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr);
}
$db->free($result3);
}
else $error++;
// Sort array // Sort array
if (! $error) if (! $error)
@ -228,7 +208,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$num = count($tab_sqlobj); $num = count($tab_sqlobj);
//$num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
@ -236,7 +215,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$ref = ''; $ref = '';
$refcomp = ''; $refcomp = '';
//$obj = $db->fetch_object($result);
$obj = array_shift($tab_sqlobj); $obj = array_shift($tab_sqlobj);
if ($obj->family == 'invoice_supplier') if ($obj->family == 'invoice_supplier')
@ -284,6 +262,14 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$paiement = -1*$socialcontribstatic->getSommePaiement(); // Payment already done $paiement = -1*$socialcontribstatic->getSommePaiement(); // Payment already done
} }
$parameters = array('obj' => $obj);
$reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if(empty($reshook)){
$ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : '';
$refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : '';
$paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0;
}
$total_ttc = $obj->total_ttc; $total_ttc = $obj->total_ttc;
if ($paiement) $total_ttc = $obj->total_ttc - $paiement; if ($paiement) $total_ttc = $obj->total_ttc - $paiement;
$solde += $total_ttc; $solde += $total_ttc;
@ -291,8 +277,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
// We discard lines with a remainder to pay to 0 // We discard lines with a remainder to pay to 0
if (price2num($total_ttc) != 0) if (price2num($total_ttc) != 0)
{ {
// Show line // Show line
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
@ -315,8 +299,15 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
dol_print_error($db); dol_print_error($db);
} }
// Solde actuel // Other lines
$parameters = array('solde' => $solde);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if(empty($reshook)){
print $hookmanager->resPrint;
$solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde;
}
// solde
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td align="left" colspan="5">'.$langs->trans("FutureBalance").' ('.$object->currency_code.')</td>'; print '<td align="left" colspan="5">'.$langs->trans("FutureBalance").' ('.$object->currency_code.')</td>';
print '<td align="right" class="nowrap">'.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).'</td>'; print '<td align="right" class="nowrap">'.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).'</td>';