Fix travis
This commit is contained in:
parent
02aa4f7e0c
commit
4bae65bedc
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -50,7 +50,7 @@ $object->id = $socid;
|
||||
$object->fetch($socid);
|
||||
$form = new Form($db);
|
||||
|
||||
$BookKeeping = new lettering($db);
|
||||
$BookKeeping = new lettering($db);
|
||||
|
||||
if ($sortorder == "") $sortorder = "ASC";
|
||||
if ($sortfield == "") $sortfield = "bk.rowid";
|
||||
@ -65,11 +65,11 @@ $formaccounting = new FormAccounting($db);
|
||||
if ($action == 'lettering') {
|
||||
|
||||
$result = $BookKeeping->updatelettrage($_POST['ids']);
|
||||
|
||||
// var_dump($result);
|
||||
|
||||
// var_dump($result);
|
||||
if( $result < 0 ){
|
||||
setEventMessages('', $BookKeeping->errors, 'errors' );
|
||||
$error++;
|
||||
$error++;
|
||||
|
||||
}
|
||||
}
|
||||
@ -77,29 +77,29 @@ if ($action == 'lettering') {
|
||||
if ($action == 'autolettrage') {
|
||||
|
||||
$result = $BookKeeping->LettrageTiers($socid);
|
||||
|
||||
|
||||
if( $result < 0 ){
|
||||
setEventMessages('', $BookKeeping->errors, 'errors' );
|
||||
$error++;
|
||||
$error++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
llxHeader ( '', 'Compta - Grand Livre' );
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
|
||||
|
||||
|
||||
dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print '<table width="100%" class="border">';
|
||||
@ -129,7 +129,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
// Address
|
||||
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
|
||||
@ -147,41 +147,41 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
|
||||
else print ($img?$img.' ':'').$object->country;
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
$sql .= " WHERE (bk.code_tiers = '" . $object->code_compta . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER. "' )" ;
|
||||
|
||||
|
||||
|
||||
|
||||
if (dol_strlen ( $search_year )) {
|
||||
$sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql .= " ORDER BY bk.lettering_code ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset );
|
||||
|
||||
// echo $sql;
|
||||
|
||||
// echo $sql;
|
||||
// dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG );
|
||||
$resql = $db->query ( $sql );
|
||||
if ($resql) {
|
||||
$num = $db->num_rows ( $resql );
|
||||
$i = 0;
|
||||
|
||||
|
||||
|
||||
print '<form name="add" action="?socid='.$object->id.'" method="POST">';
|
||||
print '<input type="hidden" name="action" value="lettering">';
|
||||
print '<input type="hidden" name="socid" value="'.$object->id.'">';
|
||||
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print_liste_field_titre ( $langs->trans ( "Doctype" ), "liste.php", "bk.doc_type" );
|
||||
print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" );
|
||||
print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" );
|
||||
@ -193,10 +193,10 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
// print_liste_field_titre ( $langs->trans ( "Amount" ), "liste.php", "bk.montant" );
|
||||
// print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" );
|
||||
print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" );
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<form action="" method="GET">';
|
||||
print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">';
|
||||
@ -218,29 +218,29 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print '<td> </td>';
|
||||
print '</form>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$var = false;
|
||||
|
||||
$debit = 0;
|
||||
$credit = 0;
|
||||
$solde = 0;
|
||||
$tmp = '';
|
||||
|
||||
$debit = 0;
|
||||
$credit = 0;
|
||||
$solde = 0;
|
||||
$tmp = '';
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object ( $resql );
|
||||
|
||||
|
||||
if($tmp !=$obj->lettering_code || empty($tmp) )
|
||||
$tmp =$obj->lettering_code;
|
||||
|
||||
if($tmp !=$obj->lettering_code || empty($obj->lettering_code))
|
||||
|
||||
if($tmp !=$obj->lettering_code || empty($obj->lettering_code))
|
||||
$var = ! $var;
|
||||
|
||||
|
||||
$debit+= $obj->debit;
|
||||
$credit+= $obj->credit;
|
||||
|
||||
|
||||
|
||||
$debit+= $obj->debit;
|
||||
$credit+= $obj->credit;
|
||||
|
||||
$solde+=($obj->credit-$obj->debit);
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
|
||||
print '<td>' . $obj->rowid . '</td>';
|
||||
if(empty($obj->lettering_code)){
|
||||
print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">';
|
||||
@ -249,9 +249,9 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
}
|
||||
else
|
||||
print '<td>'.$obj->doc_type . '</td>' . "\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>';
|
||||
print '<td>' . $obj->doc_ref . '</td>';
|
||||
// print '<td>' . $obj->numero_compte . '</td>';
|
||||
@ -263,24 +263,24 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
// print '<td>' . $obj->sens . '</td>';
|
||||
print '<td>' . $obj->code_journal . '</td>';
|
||||
print '<td>' . round($solde, 2) . '</td>';
|
||||
|
||||
|
||||
if(empty($obj->lettering_code)){
|
||||
print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>';
|
||||
}
|
||||
else
|
||||
print '<td>' . $obj->lettering_code . '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i ++;
|
||||
|
||||
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i ++;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td colspan="4">Mouvement totaux</td>' . "\n";
|
||||
print '<td></td>';
|
||||
// print '<td></td>';
|
||||
@ -292,7 +292,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print '<td></td>';
|
||||
print '<td> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td colspan="5">Solde Comptable</td>' . "\n";
|
||||
// print '<td></td>';
|
||||
@ -304,19 +304,19 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print '<td></td>';
|
||||
print '<td> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
print '<input class="butAction" type="submit" value="lettering">';
|
||||
print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>';
|
||||
print "</form>";
|
||||
$db->free ( $resql );
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error ( $db );
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -52,7 +52,7 @@ $object->id = $socid;
|
||||
$object->fetch($socid);
|
||||
$form = new Form($db);
|
||||
|
||||
$BookKeeping = new lettering($db);
|
||||
$BookKeeping = new lettering($db);
|
||||
|
||||
if ($sortorder == "") $sortorder = "ASC";
|
||||
if ($sortfield == "") $sortfield = "bk.rowid";
|
||||
@ -67,11 +67,11 @@ $formaccounting = new FormAccounting($db);
|
||||
if ($action == 'lettering') {
|
||||
|
||||
$result = $BookKeeping->updatelettrage($_POST['ids']);
|
||||
|
||||
// var_dump($result);
|
||||
|
||||
// var_dump($result);
|
||||
if( $result < 0 ){
|
||||
setEventMessages('', $BookKeeping->errors, 'errors' );
|
||||
$error++;
|
||||
$error++;
|
||||
|
||||
}
|
||||
}
|
||||
@ -79,29 +79,29 @@ if ($action == 'lettering') {
|
||||
if ($action == 'autolettrage') {
|
||||
|
||||
$result = $BookKeeping->LettrageTiers($socid);
|
||||
|
||||
|
||||
if( $result < 0 ){
|
||||
setEventMessages('', $BookKeeping->errors, 'errors' );
|
||||
$error++;
|
||||
$error++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
llxHeader ( '', 'Compta - Grand Livre' );
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
|
||||
|
||||
|
||||
dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print '<table width="100%" class="border">';
|
||||
@ -131,7 +131,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
// Address
|
||||
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
|
||||
@ -149,49 +149,49 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
|
||||
else print ($img?$img.' ':'').$object->country;
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
// print_r($soc);
|
||||
// exit;
|
||||
|
||||
// print_r($soc);
|
||||
// exit;
|
||||
// [code_compta] => 411DOUA
|
||||
// [code_compta_fournisseur] => 401SUPPCODE
|
||||
|
||||
|
||||
/*
|
||||
* Mode Liste
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
$sql .= " WHERE (bk.code_tiers = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER. "' )" ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (dol_strlen ( $search_year )) {
|
||||
$sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql .= " ORDER BY bk.lettering ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset );
|
||||
|
||||
// echo $sql;
|
||||
|
||||
// echo $sql;
|
||||
// dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG );
|
||||
$resql = $db->query ( $sql );
|
||||
if ($resql) {
|
||||
$num = $db->num_rows ( $resql );
|
||||
$i = 0;
|
||||
|
||||
|
||||
|
||||
print '<form name="add" action="?socid='.$object->id.'" method="POST">';
|
||||
print '<input type="hidden" name="action" value="lettering">';
|
||||
print '<input type="hidden" name="socid" value="'.$object->id.'">';
|
||||
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print_liste_field_titre ( $langs->trans ( "Doctype" ), "liste.php", "bk.doc_type" );
|
||||
print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" );
|
||||
print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" );
|
||||
@ -203,10 +203,10 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print_liste_field_titre ( $langs->trans ( "Amount" ), "liste.php", "bk.montant" );
|
||||
print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" );
|
||||
print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" );
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<form action="" method="GET">';
|
||||
print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">';
|
||||
@ -228,29 +228,29 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print '<td> </td>';
|
||||
print '</form>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$var = false;
|
||||
|
||||
$debit = 0;
|
||||
$credit = 0;
|
||||
$solde = 0;
|
||||
$tmp = '';
|
||||
|
||||
$debit = 0;
|
||||
$credit = 0;
|
||||
$solde = 0;
|
||||
$tmp = '';
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object ( $resql );
|
||||
|
||||
|
||||
if($tmp !=$obj->lettering || empty($tmp) )
|
||||
$tmp =$obj->lettering;
|
||||
|
||||
if($tmp !=$obj->lettering || empty($obj->lettering))
|
||||
|
||||
if($tmp !=$obj->lettering || empty($obj->lettering))
|
||||
$var = ! $var;
|
||||
|
||||
|
||||
$debit+= $obj->debit;
|
||||
$credit+= $obj->credit;
|
||||
|
||||
|
||||
|
||||
$debit+= $obj->debit;
|
||||
$credit+= $obj->credit;
|
||||
|
||||
$solde+=($obj->credit-$obj->debit);
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
|
||||
print '<td>' . $obj->rowid . '</td>';
|
||||
if(empty($obj->lettering)){
|
||||
print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">';
|
||||
@ -259,9 +259,9 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
}
|
||||
else
|
||||
print '<td>'.$obj->doc_type . '</td>' . "\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>';
|
||||
print '<td>' . $obj->doc_ref . '</td>';
|
||||
// print '<td>' . $obj->numero_compte . '</td>';
|
||||
@ -273,24 +273,20 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print '<td>' . $obj->sens . '</td>';
|
||||
print '<td>' . $obj->code_journal . '</td>';
|
||||
print '<td>' . round($solde, 2) . '</td>';
|
||||
|
||||
|
||||
if(empty($obj->lettering)){
|
||||
print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>';
|
||||
}
|
||||
else
|
||||
print '<td>' . $obj->lettering . '</td>';
|
||||
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
$i ++;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td colspan="4">Mouvement totaux</td>' . "\n";
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
@ -302,7 +298,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print '<td></td>';
|
||||
print '<td> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td colspan="5">Solde Comptable</td>' . "\n";
|
||||
print '<td></td>';
|
||||
@ -314,9 +310,9 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print '<td></td>';
|
||||
print '<td> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
print '<input class="butAction" type="submit" value="lettering">';
|
||||
print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>';
|
||||
print "</form>";
|
||||
@ -325,8 +321,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
dol_print_error ( $db );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
|
||||
@ -22,33 +22,34 @@
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Fichier de la classe des comptes comptable
|
||||
*/
|
||||
error_reporting(0);
|
||||
|
||||
dol_include_once ( "/accountancy/class/bookkeeping.class.php");
|
||||
dol_include_once ( "/societe/class/societe.class.php");
|
||||
dol_include_once ( "/core/lib/date.lib.php"); // see if not useless for dol(now)
|
||||
include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php";
|
||||
include_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
|
||||
include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
|
||||
|
||||
class lettering
|
||||
extends BookKeeping {
|
||||
|
||||
|
||||
/**
|
||||
* Class lettering
|
||||
*/
|
||||
class lettering extends BookKeeping {
|
||||
|
||||
public function LettrageTiers($socid){
|
||||
|
||||
$db = $this->db;
|
||||
|
||||
|
||||
$db = $this->db;
|
||||
|
||||
$object = new Societe($this->db);
|
||||
$object->id = $socid;
|
||||
$object->fetch($socid);
|
||||
|
||||
|
||||
if( $object->code_compta == '411CUSTCODE')
|
||||
$object->code_compta = '';
|
||||
|
||||
if( $object->code_compta_fournisseur == '401SUPPCODE')
|
||||
$object->code_compta_fournisseur = '';
|
||||
if( $object->code_compta == '411CUSTCODE')
|
||||
$object->code_compta = '';
|
||||
|
||||
if( $object->code_compta_fournisseur == '401SUPPCODE')
|
||||
$object->code_compta_fournisseur = '';
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.lettering_code, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
$sql .= " WHERE code_journal = 'BQ' AND ( ";
|
||||
@ -58,17 +59,17 @@ class lettering
|
||||
$sql .= " OR ";
|
||||
if(!empty($object->code_compta_fournisseur) )
|
||||
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
|
||||
|
||||
|
||||
$sql .= " ) AND ( bk.date_lettering ='' OR bk.date_lettering IS NULL ) AND bk.lettering_code !='' ";
|
||||
|
||||
|
||||
$sql .= " GROUP BY bk.lettering_code ";
|
||||
|
||||
|
||||
|
||||
|
||||
$resql = $db->query ( $sql );
|
||||
if ($resql) {
|
||||
$num = $db->num_rows ( $resql );
|
||||
$i = 0;
|
||||
|
||||
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object ( $resql );
|
||||
$i++;
|
||||
@ -84,7 +85,7 @@ class lettering
|
||||
if(!empty($object->code_compta_fournisseur) )
|
||||
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
|
||||
$sql .= " ) ";
|
||||
// echo $sql;
|
||||
// echo $sql;
|
||||
$resql2 = $db->query ( $sql );
|
||||
if ($resql2) {
|
||||
$num2 = $db->num_rows ( $resql2 );
|
||||
@ -95,25 +96,25 @@ class lettering
|
||||
$i2++;
|
||||
$ids[] = $obj2->rowid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(count($ids) > 1 ){
|
||||
$result = $this->updatelettrage($ids);
|
||||
|
||||
// var_dump($result);
|
||||
|
||||
// var_dump($result);
|
||||
// if( $result < 0 ){
|
||||
// setEventMessages('', $BookKeeping->errors, 'errors' );
|
||||
// $error++;
|
||||
//
|
||||
// $error++;
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Prise en charge des lettering complexe avec prelevment , virement
|
||||
Prise en charge des lettering complexe avec prelevment , virement
|
||||
*/
|
||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
|
||||
@ -125,29 +126,29 @@ class lettering
|
||||
$sql .= " OR ";
|
||||
if(!empty($object->code_compta_fournisseur) )
|
||||
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
|
||||
|
||||
|
||||
$sql .= " ) AND date_lettering ='' ";
|
||||
$sql .= " GROUP BY bk.lettering_code ";
|
||||
|
||||
// echo $sql;
|
||||
//
|
||||
|
||||
// echo $sql;
|
||||
//
|
||||
$resql = $db->query ( $sql );
|
||||
if ($resql) {
|
||||
$num = $db->num_rows ( $resql );
|
||||
$i = 0;
|
||||
|
||||
|
||||
while ( $i < $num ) {
|
||||
$obj = $db->fetch_object ( $resql );
|
||||
$ids = array();
|
||||
$i++;
|
||||
|
||||
// print_r($obj);
|
||||
|
||||
|
||||
|
||||
if($obj->type =='payment_supplier' ) {
|
||||
// print_r($obj);
|
||||
|
||||
|
||||
|
||||
if($obj->type =='payment_supplier' ) {
|
||||
$ids[] = $obj->rowid;
|
||||
|
||||
|
||||
$sql= 'SELECT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank ';
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
|
||||
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
|
||||
@ -166,12 +167,12 @@ class lettering
|
||||
if(!empty($object->code_compta_fournisseur) )
|
||||
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
|
||||
$sql .= " ) ";
|
||||
// echo $sql;
|
||||
// exit;
|
||||
// echo $sql;
|
||||
// exit;
|
||||
}
|
||||
elseif($obj->type =='payment' ){
|
||||
$ids[] = $obj->rowid;
|
||||
|
||||
|
||||
$sql= 'SELECT bk.rowid,fac.facnumber , pay.fk_bank ';
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
|
||||
@ -188,108 +189,108 @@ class lettering
|
||||
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
|
||||
$sql .= " ) ";
|
||||
|
||||
// echo $sql;
|
||||
// echo $sql;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$resql2 = $db->query ( $sql );
|
||||
if ($resql2) {
|
||||
$num2 = $db->num_rows ( $resql2 );
|
||||
$i2 = 0;
|
||||
|
||||
|
||||
while ( $i2 < $num2 ) {
|
||||
$obj2 = $db->fetch_object ( $resql2 );
|
||||
$i2++;
|
||||
$ids[] = $obj2->rowid;
|
||||
}
|
||||
|
||||
// print_r($ids);
|
||||
|
||||
// print_r($ids);
|
||||
// exit;
|
||||
if(count($ids) > 1 ){
|
||||
$result = $this->updatelettrage($ids);
|
||||
|
||||
// var_dump($result);
|
||||
|
||||
// var_dump($result);
|
||||
// if( $result < 0 ){
|
||||
// setEventMessages('', $BookKeeping->errors, 'errors' );
|
||||
// $error++;
|
||||
//
|
||||
// $error++;
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
// exit;
|
||||
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function updatelettrage($ids, $notrigger=false){
|
||||
$error = 0;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$sql = "SELECT lettering_code FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
|
||||
$sql .= " lettering_code != '' GROUP BY lettering_code ORDER BY lettering_code DESC limit 1; ";
|
||||
// echo $sql;
|
||||
// echo $sql;
|
||||
$result = $this->db->query ( $sql );
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object ( $result );
|
||||
$lettre = (empty($obj->lettering_code)? 'AAA' : $obj->lettering_code );
|
||||
$lettre = (empty($obj->lettering_code)? 'AAA' : $obj->lettering_code );
|
||||
if(!empty($obj->lettering_code))
|
||||
$lettre++;
|
||||
$lettre++;
|
||||
}
|
||||
else{
|
||||
$this->errors[] = 'Error'.$this->db->lasterror();;
|
||||
$this->errors[] = 'Error'.$this->db->lasterror();;
|
||||
$error++;
|
||||
}
|
||||
// var_dump(__line__, $error);
|
||||
|
||||
// var_dump(__line__, $error);
|
||||
|
||||
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
|
||||
$sql .= " rowid IN (".implode(',', $ids).") ";
|
||||
$result = $this->db->query ( $sql );
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object ( $result );
|
||||
// print_r($obj);
|
||||
// print_r($obj);
|
||||
if( !(round(abs($obj->deb),2) === round(abs($obj->cred),2)) ){
|
||||
// echo $sql;
|
||||
// print_r($obj);
|
||||
$this->errors[] = 'Total not exacts '.round(abs($obj->deb),2).' vs '. round(abs($obj->cred),2);
|
||||
$error++;
|
||||
// echo $sql;
|
||||
// print_r($obj);
|
||||
$this->errors[] = 'Total not exacts '.round(abs($obj->deb),2).' vs '. round(abs($obj->cred),2);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$this->errors[] = 'Erreur sql'.$this->db->lasterror();;
|
||||
$this->errors[] = 'Erreur sql'.$this->db->lasterror();;
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Update request
|
||||
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
|
||||
$sql.= " lettering_code='".$lettre."'";
|
||||
$sql.= " , date_lettering = " .$now ; // todo correct date it's false
|
||||
$sql.= " , date_lettering = " .$now ; // todo correct date it's false
|
||||
$sql.= " WHERE rowid IN (".implode(',', $ids).") ";
|
||||
// echo $sql ;
|
||||
//
|
||||
// var_dump(__line__, $error);
|
||||
// print_r($this->errors);
|
||||
// exit;
|
||||
// echo $sql ;
|
||||
//
|
||||
// var_dump(__line__, $error);
|
||||
// print_r($this->errors);
|
||||
// exit;
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::update sql=".$sql, 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 calls a trigger.
|
||||
|
||||
|
||||
//// Call triggers
|
||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
//$interface=new Interfaces($this->db);
|
||||
@ -298,7 +299,7 @@ class lettering
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
// var_dump(__line__, $error);
|
||||
// var_dump(__line__, $error);
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
@ -308,8 +309,8 @@ class lettering
|
||||
// $this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
// }
|
||||
$this->db->rollback();
|
||||
// echo $this->error;
|
||||
// var_dump(__line__, $error);
|
||||
// echo $this->error;
|
||||
// var_dump(__line__, $error);
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
@ -318,10 +319,6 @@ class lettering
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
@ -28,6 +28,7 @@
|
||||
* \ingroup Advanced accountancy
|
||||
* \brief Page with sells journal
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user