Fix travis

This commit is contained in:
Laurent Destailleur 2017-07-07 22:04:29 +02:00
parent 02aa4f7e0c
commit 4bae65bedc
4 changed files with 214 additions and 221 deletions

View File

@ -3,7 +3,7 @@
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -50,7 +50,7 @@ $object->id = $socid;
$object->fetch($socid); $object->fetch($socid);
$form = new Form($db); $form = new Form($db);
$BookKeeping = new lettering($db); $BookKeeping = new lettering($db);
if ($sortorder == "") $sortorder = "ASC"; if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "bk.rowid"; if ($sortfield == "") $sortfield = "bk.rowid";
@ -65,11 +65,11 @@ $formaccounting = new FormAccounting($db);
if ($action == 'lettering') { if ($action == 'lettering') {
$result = $BookKeeping->updatelettrage($_POST['ids']); $result = $BookKeeping->updatelettrage($_POST['ids']);
// var_dump($result); // var_dump($result);
if( $result < 0 ){ if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' ); setEventMessages('', $BookKeeping->errors, 'errors' );
$error++; $error++;
} }
} }
@ -77,29 +77,29 @@ if ($action == 'lettering') {
if ($action == 'autolettrage') { if ($action == 'autolettrage') {
$result = $BookKeeping->LettrageTiers($socid); $result = $BookKeeping->LettrageTiers($socid);
if( $result < 0 ){ if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' ); setEventMessages('', $BookKeeping->errors, 'errors' );
$error++; $error++;
} }
} }
llxHeader ( '', 'Compta - Grand Livre' ); llxHeader ( '', 'Compta - Grand Livre' );
/* /*
* Affichage onglets * Affichage onglets
*/ */
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company');
print '<table width="100%" class="border">'; 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 $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Address // Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'; 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); if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$object->country; else print ($img?$img.' ':'').$object->country;
print '</td></tr>'; print '</td></tr>';
print '</table>'; 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 = "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 .= " 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. "' )" ; $sql .= " WHERE (bk.code_tiers = '" . $object->code_compta . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER. "' )" ;
if (dol_strlen ( $search_year )) { if (dol_strlen ( $search_year )) {
$sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )"; $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 ); $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 ); // dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG );
$resql = $db->query ( $sql ); $resql = $db->query ( $sql );
if ($resql) { if ($resql) {
$num = $db->num_rows ( $resql ); $num = $db->num_rows ( $resql );
$i = 0; $i = 0;
print '<form name="add" action="?socid='.$object->id.'" method="POST">'; print '<form name="add" action="?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="action" value="lettering">'; print '<input type="hidden" name="action" value="lettering">';
print '<input type="hidden" name="socid" value="'.$object->id.'">'; print '<input type="hidden" name="socid" value="'.$object->id.'">';
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">'; 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 ( "Doctype" ), "liste.php", "bk.doc_type" );
print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" ); print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" );
print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" ); 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 ( "Amount" ), "liste.php", "bk.montant" );
// print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" ); // print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" );
print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" ); 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>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<form action="" method="GET">'; print '<form action="" method="GET">';
print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">'; print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">';
@ -218,29 +218,29 @@ llxHeader ( '', 'Compta - Grand Livre' );
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</form>'; print '</form>';
print '</tr>'; print '</tr>';
$var = false; $var = false;
$debit = 0; $debit = 0;
$credit = 0; $credit = 0;
$solde = 0; $solde = 0;
$tmp = ''; $tmp = '';
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object ( $resql ); $obj = $db->fetch_object ( $resql );
if($tmp !=$obj->lettering_code || empty($tmp) ) if($tmp !=$obj->lettering_code || empty($tmp) )
$tmp =$obj->lettering_code; $tmp =$obj->lettering_code;
if($tmp !=$obj->lettering_code || empty($obj->lettering_code)) if($tmp !=$obj->lettering_code || empty($obj->lettering_code))
$var = ! $var; $var = ! $var;
$debit+= $obj->debit; $debit+= $obj->debit;
$credit+= $obj->credit; $credit+= $obj->credit;
$solde+=($obj->credit-$obj->debit); $solde+=($obj->credit-$obj->debit);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>' . $obj->rowid . '</td>'; print '<td>' . $obj->rowid . '</td>';
if(empty($obj->lettering_code)){ if(empty($obj->lettering_code)){
print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">'; 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 else
print '<td>'.$obj->doc_type . '</td>' . "\n"; print '<td>'.$obj->doc_type . '</td>' . "\n";
print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>'; print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>';
print '<td>' . $obj->doc_ref . '</td>'; print '<td>' . $obj->doc_ref . '</td>';
// print '<td>' . $obj->numero_compte . '</td>'; // print '<td>' . $obj->numero_compte . '</td>';
@ -263,24 +263,24 @@ llxHeader ( '', 'Compta - Grand Livre' );
// print '<td>' . $obj->sens . '</td>'; // print '<td>' . $obj->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>'; print '<td>' . $obj->code_journal . '</td>';
print '<td>' . round($solde, 2) . '</td>'; print '<td>' . round($solde, 2) . '</td>';
if(empty($obj->lettering_code)){ if(empty($obj->lettering_code)){
print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>'; print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>';
} }
else else
print '<td>' . $obj->lettering_code . '</td>'; 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 colspan="4">Mouvement totaux</td>' . "\n";
print '<td></td>'; print '<td></td>';
// print '<td></td>'; // print '<td></td>';
@ -292,7 +292,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
print '<td></td>'; print '<td></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td colspan="5">Solde Comptable</td>' . "\n"; print '<td colspan="5">Solde Comptable</td>' . "\n";
// print '<td></td>'; // print '<td></td>';
@ -304,19 +304,19 @@ llxHeader ( '', 'Compta - Grand Livre' );
print '<td></td>'; print '<td></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
print "</table>"; print "</table>";
print '<input class="butAction" type="submit" value="lettering">'; print '<input class="butAction" type="submit" value="lettering">';
print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>'; print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>';
print "</form>"; print "</form>";
$db->free ( $resql ); $db->free($resql);
} else { } else {
dol_print_error ( $db ); dol_print_error($db);
} }
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
?>

View File

@ -3,7 +3,7 @@
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -52,7 +52,7 @@ $object->id = $socid;
$object->fetch($socid); $object->fetch($socid);
$form = new Form($db); $form = new Form($db);
$BookKeeping = new lettering($db); $BookKeeping = new lettering($db);
if ($sortorder == "") $sortorder = "ASC"; if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "bk.rowid"; if ($sortfield == "") $sortfield = "bk.rowid";
@ -67,11 +67,11 @@ $formaccounting = new FormAccounting($db);
if ($action == 'lettering') { if ($action == 'lettering') {
$result = $BookKeeping->updatelettrage($_POST['ids']); $result = $BookKeeping->updatelettrage($_POST['ids']);
// var_dump($result); // var_dump($result);
if( $result < 0 ){ if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' ); setEventMessages('', $BookKeeping->errors, 'errors' );
$error++; $error++;
} }
} }
@ -79,29 +79,29 @@ if ($action == 'lettering') {
if ($action == 'autolettrage') { if ($action == 'autolettrage') {
$result = $BookKeeping->LettrageTiers($socid); $result = $BookKeeping->LettrageTiers($socid);
if( $result < 0 ){ if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' ); setEventMessages('', $BookKeeping->errors, 'errors' );
$error++; $error++;
} }
} }
llxHeader ( '', 'Compta - Grand Livre' ); llxHeader ( '', 'Compta - Grand Livre' );
/* /*
* Affichage onglets * Affichage onglets
*/ */
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company');
print '<table width="100%" class="border">'; 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 $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Address // Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'; 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); if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$object->country; else print ($img?$img.' ':'').$object->country;
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
// print_r($soc); // print_r($soc);
// exit; // exit;
// [code_compta] => 411DOUA // [code_compta] => 411DOUA
// [code_compta_fournisseur] => 401SUPPCODE // [code_compta_fournisseur] => 401SUPPCODE
/* /*
* Mode Liste * 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 = "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 .= " 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. "' )" ; $sql .= " WHERE (bk.code_tiers = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER. "' )" ;
if (dol_strlen ( $search_year )) { if (dol_strlen ( $search_year )) {
$sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )"; $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 ); $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 ); // dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG );
$resql = $db->query ( $sql ); $resql = $db->query ( $sql );
if ($resql) { if ($resql) {
$num = $db->num_rows ( $resql ); $num = $db->num_rows ( $resql );
$i = 0; $i = 0;
print '<form name="add" action="?socid='.$object->id.'" method="POST">'; print '<form name="add" action="?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="action" value="lettering">'; print '<input type="hidden" name="action" value="lettering">';
print '<input type="hidden" name="socid" value="'.$object->id.'">'; print '<input type="hidden" name="socid" value="'.$object->id.'">';
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">'; 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 ( "Doctype" ), "liste.php", "bk.doc_type" );
print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" ); print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" );
print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" ); 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 ( "Amount" ), "liste.php", "bk.montant" );
print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" ); print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" );
print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" ); 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>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<form action="" method="GET">'; print '<form action="" method="GET">';
print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">'; print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">';
@ -228,29 +228,29 @@ llxHeader ( '', 'Compta - Grand Livre' );
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</form>'; print '</form>';
print '</tr>'; print '</tr>';
$var = false; $var = false;
$debit = 0; $debit = 0;
$credit = 0; $credit = 0;
$solde = 0; $solde = 0;
$tmp = ''; $tmp = '';
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object ( $resql ); $obj = $db->fetch_object ( $resql );
if($tmp !=$obj->lettering || empty($tmp) ) if($tmp !=$obj->lettering || empty($tmp) )
$tmp =$obj->lettering; $tmp =$obj->lettering;
if($tmp !=$obj->lettering || empty($obj->lettering)) if($tmp !=$obj->lettering || empty($obj->lettering))
$var = ! $var; $var = ! $var;
$debit+= $obj->debit; $debit+= $obj->debit;
$credit+= $obj->credit; $credit+= $obj->credit;
$solde+=($obj->credit-$obj->debit); $solde+=($obj->credit-$obj->debit);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>' . $obj->rowid . '</td>'; print '<td>' . $obj->rowid . '</td>';
if(empty($obj->lettering)){ if(empty($obj->lettering)){
print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">'; 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 else
print '<td>'.$obj->doc_type . '</td>' . "\n"; print '<td>'.$obj->doc_type . '</td>' . "\n";
print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>'; print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>';
print '<td>' . $obj->doc_ref . '</td>'; print '<td>' . $obj->doc_ref . '</td>';
// print '<td>' . $obj->numero_compte . '</td>'; // print '<td>' . $obj->numero_compte . '</td>';
@ -273,24 +273,20 @@ llxHeader ( '', 'Compta - Grand Livre' );
print '<td>' . $obj->sens . '</td>'; print '<td>' . $obj->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>'; print '<td>' . $obj->code_journal . '</td>';
print '<td>' . round($solde, 2) . '</td>'; print '<td>' . round($solde, 2) . '</td>';
if(empty($obj->lettering)){ if(empty($obj->lettering)){
print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>'; print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>';
} }
else else
print '<td>' . $obj->lettering . '</td>'; print '<td>' . $obj->lettering . '</td>';
print "</tr>\n"; print "</tr>\n";
$i ++; $i ++;
} }
print "<tr $bc[$var]>"; print '<tr class="oddeven">';
print '<td colspan="4">Mouvement totaux</td>' . "\n"; print '<td colspan="4">Mouvement totaux</td>' . "\n";
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
@ -302,7 +298,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
print '<td></td>'; print '<td></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td colspan="5">Solde Comptable</td>' . "\n"; print '<td colspan="5">Solde Comptable</td>' . "\n";
print '<td></td>'; print '<td></td>';
@ -314,9 +310,9 @@ llxHeader ( '', 'Compta - Grand Livre' );
print '<td></td>'; print '<td></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
print "</table>"; print "</table>";
print '<input class="butAction" type="submit" value="lettering">'; print '<input class="butAction" type="submit" value="lettering">';
print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>'; print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>';
print "</form>"; print "</form>";
@ -325,8 +321,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
dol_print_error ( $db ); dol_print_error ( $db );
} }
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();
?>

View File

@ -22,33 +22,34 @@
* \ingroup Accounting Expert * \ingroup Accounting Expert
* \brief Fichier de la classe des comptes comptable * \brief Fichier de la classe des comptes comptable
*/ */
error_reporting(0);
dol_include_once ( "/accountancy/class/bookkeeping.class.php"); include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php";
dol_include_once ( "/societe/class/societe.class.php"); include_once DOL_DOCUMENT_ROOT."/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."/core/lib/date.lib.php";
class lettering
extends BookKeeping {
/**
* Class lettering
*/
class lettering extends BookKeeping {
public function LettrageTiers($socid){ public function LettrageTiers($socid){
$db = $this->db; $db = $this->db;
$object = new Societe($this->db); $object = new Societe($this->db);
$object->id = $socid; $object->id = $socid;
$object->fetch($socid); $object->fetch($socid);
if( $object->code_compta == '411CUSTCODE') if( $object->code_compta == '411CUSTCODE')
$object->code_compta = ''; $object->code_compta = '';
if( $object->code_compta_fournisseur == '401SUPPCODE') if( $object->code_compta_fournisseur == '401SUPPCODE')
$object->code_compta_fournisseur = ''; $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 = "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 .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE code_journal = 'BQ' AND ( "; $sql .= " WHERE code_journal = 'BQ' AND ( ";
@ -58,17 +59,17 @@ class lettering
$sql .= " OR "; $sql .= " OR ";
if(!empty($object->code_compta_fournisseur) ) if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $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 .= " ) AND ( bk.date_lettering ='' OR bk.date_lettering IS NULL ) AND bk.lettering_code !='' ";
$sql .= " GROUP BY bk.lettering_code "; $sql .= " GROUP BY bk.lettering_code ";
$resql = $db->query ( $sql ); $resql = $db->query ( $sql );
if ($resql) { if ($resql) {
$num = $db->num_rows ( $resql ); $num = $db->num_rows ( $resql );
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object ( $resql ); $obj = $db->fetch_object ( $resql );
$i++; $i++;
@ -84,7 +85,7 @@ class lettering
if(!empty($object->code_compta_fournisseur) ) if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) "; $sql .= " ) ";
// echo $sql; // echo $sql;
$resql2 = $db->query ( $sql ); $resql2 = $db->query ( $sql );
if ($resql2) { if ($resql2) {
$num2 = $db->num_rows ( $resql2 ); $num2 = $db->num_rows ( $resql2 );
@ -95,25 +96,25 @@ class lettering
$i2++; $i2++;
$ids[] = $obj2->rowid; $ids[] = $obj2->rowid;
} }
if(count($ids) > 1 ){ if(count($ids) > 1 ){
$result = $this->updatelettrage($ids); $result = $this->updatelettrage($ids);
// var_dump($result); // var_dump($result);
// if( $result < 0 ){ // if( $result < 0 ){
// setEventMessages('', $BookKeeping->errors, 'errors' ); // 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 = "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"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
@ -125,29 +126,29 @@ class lettering
$sql .= " OR "; $sql .= " OR ";
if(!empty($object->code_compta_fournisseur) ) if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) AND date_lettering ='' "; $sql .= " ) AND date_lettering ='' ";
$sql .= " GROUP BY bk.lettering_code "; $sql .= " GROUP BY bk.lettering_code ";
// echo $sql; // echo $sql;
// //
$resql = $db->query ( $sql ); $resql = $db->query ( $sql );
if ($resql) { if ($resql) {
$num = $db->num_rows ( $resql ); $num = $db->num_rows ( $resql );
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object ( $resql ); $obj = $db->fetch_object ( $resql );
$ids = array(); $ids = array();
$i++; $i++;
// print_r($obj);
// print_r($obj);
if($obj->type =='payment_supplier' ) {
if($obj->type =='payment_supplier' ) {
$ids[] = $obj->rowid; $ids[] = $obj->rowid;
$sql= 'SELECT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank '; $sql= 'SELECT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank ';
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $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) ) if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) "; $sql .= " ) ";
// echo $sql; // echo $sql;
// exit; // exit;
} }
elseif($obj->type =='payment' ){ elseif($obj->type =='payment' ){
$ids[] = $obj->rowid; $ids[] = $obj->rowid;
$sql= 'SELECT bk.rowid,fac.facnumber , pay.fk_bank '; $sql= 'SELECT bk.rowid,fac.facnumber , pay.fk_bank ';
$sql.= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sql.= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; $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 .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) "; $sql .= " ) ";
// echo $sql; // echo $sql;
} }
$resql2 = $db->query ( $sql ); $resql2 = $db->query ( $sql );
if ($resql2) { if ($resql2) {
$num2 = $db->num_rows ( $resql2 ); $num2 = $db->num_rows ( $resql2 );
$i2 = 0; $i2 = 0;
while ( $i2 < $num2 ) { while ( $i2 < $num2 ) {
$obj2 = $db->fetch_object ( $resql2 ); $obj2 = $db->fetch_object ( $resql2 );
$i2++; $i2++;
$ids[] = $obj2->rowid; $ids[] = $obj2->rowid;
} }
// print_r($ids); // print_r($ids);
// exit; // exit;
if(count($ids) > 1 ){ if(count($ids) > 1 ){
$result = $this->updatelettrage($ids); $result = $this->updatelettrage($ids);
// var_dump($result); // var_dump($result);
// if( $result < 0 ){ // if( $result < 0 ){
// setEventMessages('', $BookKeeping->errors, 'errors' ); // setEventMessages('', $BookKeeping->errors, 'errors' );
// $error++; // $error++;
// //
// } // }
} }
// exit; // exit;
} }
} }
} }
} }
public function updatelettrage($ids, $notrigger=false){ public function updatelettrage($ids, $notrigger=false){
$error = 0; $error = 0;
$sql = "SELECT lettering_code FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; $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; "; $sql .= " lettering_code != '' GROUP BY lettering_code ORDER BY lettering_code DESC limit 1; ";
// echo $sql; // echo $sql;
$result = $this->db->query ( $sql ); $result = $this->db->query ( $sql );
if ($result) { if ($result) {
$obj = $this->db->fetch_object ( $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)) if(!empty($obj->lettering_code))
$lettre++; $lettre++;
} }
else{ else{
$this->errors[] = 'Error'.$this->db->lasterror();; $this->errors[] = 'Error'.$this->db->lasterror();;
$error++; $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 = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " rowid IN (".implode(',', $ids).") "; $sql .= " rowid IN (".implode(',', $ids).") ";
$result = $this->db->query ( $sql ); $result = $this->db->query ( $sql );
if ($result) { if ($result) {
$obj = $this->db->fetch_object ( $result ); $obj = $this->db->fetch_object ( $result );
// print_r($obj); // print_r($obj);
if( !(round(abs($obj->deb),2) === round(abs($obj->cred),2)) ){ if( !(round(abs($obj->deb),2) === round(abs($obj->cred),2)) ){
// echo $sql; // echo $sql;
// print_r($obj); // print_r($obj);
$this->errors[] = 'Total not exacts '.round(abs($obj->deb),2).' vs '. round(abs($obj->cred),2); $this->errors[] = 'Total not exacts '.round(abs($obj->deb),2).' vs '. round(abs($obj->cred),2);
$error++; $error++;
} }
} }
else{ else{
$this->errors[] = 'Erreur sql'.$this->db->lasterror();; $this->errors[] = 'Erreur sql'.$this->db->lasterror();;
$error++; $error++;
} }
// Update request // Update request
$now = dol_now(); $now = dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql.= " lettering_code='".$lettre."'"; $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).") "; $sql.= " WHERE rowid IN (".implode(',', $ids).") ";
// echo $sql ; // echo $sql ;
// //
// var_dump(__line__, $error); // var_dump(__line__, $error);
// print_r($this->errors); // print_r($this->errors);
// exit; // exit;
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error) if (! $error)
{ {
if (! $notrigger) if (! $notrigger)
{ {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger. // want this action calls a trigger.
//// Call triggers //// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db); //$interface=new Interfaces($this->db);
@ -298,7 +299,7 @@ class lettering
//// End call triggers //// End call triggers
} }
} }
// var_dump(__line__, $error); // var_dump(__line__, $error);
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
@ -308,8 +309,8 @@ class lettering
// $this->error.=($this->error?', '.$errmsg:$errmsg); // $this->error.=($this->error?', '.$errmsg:$errmsg);
// } // }
$this->db->rollback(); $this->db->rollback();
// echo $this->error; // echo $this->error;
// var_dump(__line__, $error); // var_dump(__line__, $error);
return -1*$error; return -1*$error;
} }
else else
@ -318,10 +319,6 @@ class lettering
return 1; return 1;
} }
} }
} }
?>

View File

@ -1,4 +1,4 @@
<?php <?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info> * Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
@ -28,6 +28,7 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Page with sells journal * \brief Page with sells journal
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';