fix error return
This commit is contained in:
parent
7a5353efb2
commit
33c5658209
@ -71,7 +71,7 @@ $now = dol_now();
|
|||||||
// Security check
|
// Security check
|
||||||
if ($user->societe_id > 0 && empty($id_bank_account))
|
if ($user->societe_id > 0 && empty($id_bank_account))
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -148,7 +148,7 @@ if ($result) {
|
|||||||
$tabcompany[$obj->rowid] = array (
|
$tabcompany[$obj->rowid] = array (
|
||||||
'id' => $obj->socid,
|
'id' => $obj->socid,
|
||||||
'name' => $obj->name,
|
'name' => $obj->name,
|
||||||
'code_client' => $obj->code_compta
|
'code_client' => $obj->code_compta
|
||||||
);
|
);
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
@ -251,7 +251,7 @@ if ($result) {
|
|||||||
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
|
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
|
||||||
|
|
||||||
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
||||||
|
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -312,14 +312,13 @@ if ($action == 'writebookkeeping') {
|
|||||||
if ($resultmid) {
|
if ($resultmid) {
|
||||||
$objmid = $db->fetch_object($resultmid);
|
$objmid = $db->fetch_object($resultmid);
|
||||||
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
|
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Third party
|
// Third party
|
||||||
@ -388,7 +387,7 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->code_tiers = $k;
|
$bookkeeping->code_tiers = $k;
|
||||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$bookkeeping->doc_ref = $k;
|
$bookkeeping->doc_ref = $k;
|
||||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||||
}
|
}
|
||||||
@ -396,7 +395,7 @@ if ($action == 'writebookkeeping') {
|
|||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,7 +413,7 @@ if ($action == 'export_csv') {
|
|||||||
$companystatic = new Client($db);
|
$companystatic = new Client($db);
|
||||||
|
|
||||||
// Model Cegid Expert Export
|
// Model Cegid Expert Export
|
||||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
||||||
{
|
{
|
||||||
$sep = ";";
|
$sep = ";";
|
||||||
|
|
||||||
@ -530,7 +529,7 @@ if ($action == 'export_csv') {
|
|||||||
|
|
||||||
$varlink = 'id_account=' . $id_bank_account;
|
$varlink = 'id_account=' . $id_bank_account;
|
||||||
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
|
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
|
||||||
'action' => ''
|
'action' => ''
|
||||||
), '', $varlink);
|
), '', $varlink);
|
||||||
|
|
||||||
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
||||||
@ -572,7 +571,7 @@ if ($action == 'export_csv') {
|
|||||||
|
|
||||||
foreach ( $tabpay as $key => $val ) {
|
foreach ( $tabpay as $key => $val ) {
|
||||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||||
|
|
||||||
if ($val["lib"] == '(SupplierInvoicePayment)') {
|
if ($val["lib"] == '(SupplierInvoicePayment)') {
|
||||||
$reflabel = $langs->trans('SupplierInvoicePayment');
|
$reflabel = $langs->trans('SupplierInvoicePayment');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -113,13 +113,13 @@ if ($result) {
|
|||||||
// les variables
|
// les variables
|
||||||
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef");
|
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef");
|
||||||
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||||
|
|
||||||
$tabfac = array ();
|
$tabfac = array ();
|
||||||
$tabht = array ();
|
$tabht = array ();
|
||||||
$tabtva = array ();
|
$tabtva = array ();
|
||||||
$tabttc = array ();
|
$tabttc = array ();
|
||||||
$tabcompany = array ();
|
$tabcompany = array ();
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ( $i < $num ) {
|
while ( $i < $num ) {
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
@ -133,7 +133,7 @@ if ($result) {
|
|||||||
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
|
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
|
||||||
}
|
}
|
||||||
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
||||||
|
|
||||||
$tabfac[$obj->rowid]["date"] = $obj->df;
|
$tabfac[$obj->rowid]["date"] = $obj->df;
|
||||||
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
|
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
|
||||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||||
@ -145,9 +145,9 @@ if ($result) {
|
|||||||
$tabcompany[$obj->rowid] = array (
|
$tabcompany[$obj->rowid] = array (
|
||||||
'id' => $obj->socid,
|
'id' => $obj->socid,
|
||||||
'name' => $obj->name,
|
'name' => $obj->name,
|
||||||
'code_fournisseur' => $obj->code_compta_fournisseur
|
'code_fournisseur' => $obj->code_compta_fournisseur
|
||||||
);
|
);
|
||||||
|
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -158,11 +158,11 @@ if ($result) {
|
|||||||
if ($action == 'writebookkeeping') {
|
if ($action == 'writebookkeeping') {
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
foreach ( $tabfac as $key => $val ) {
|
foreach ( $tabfac as $key => $val ) {
|
||||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||||
// get compte id and label
|
// get compte id and label
|
||||||
|
|
||||||
$bookkeeping = new BookKeeping($db);
|
$bookkeeping = new BookKeeping($db);
|
||||||
$bookkeeping->doc_date = $val["date"];
|
$bookkeeping->doc_date = $val["date"];
|
||||||
$bookkeeping->doc_ref = $val["ref"];
|
$bookkeeping->doc_ref = $val["ref"];
|
||||||
@ -179,14 +179,14 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product / Service
|
// Product / Service
|
||||||
foreach ( $tabht[$key] as $k => $mt ) {
|
foreach ( $tabht[$key] as $k => $mt ) {
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
@ -209,16 +209,16 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
// var_dump($tabtva);
|
// var_dump($tabtva);
|
||||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||||
@ -240,16 +240,16 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (empty($error)) {
|
||||||
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
||||||
}
|
}
|
||||||
@ -265,23 +265,23 @@ $companystatic = new Fournisseur($db);
|
|||||||
if ($action == 'export_csv') {
|
if ($action == 'export_csv') {
|
||||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||||
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||||
|
|
||||||
// Model Cegid Expert Export
|
// Model Cegid Expert Export
|
||||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
||||||
{
|
{
|
||||||
$sep = ";";
|
$sep = ";";
|
||||||
|
|
||||||
foreach ( $tabfac as $key => $val ) {
|
foreach ( $tabfac as $key => $val ) {
|
||||||
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
||||||
|
|
||||||
// Product / Service
|
// Product / Service
|
||||||
foreach ( $tabht[$key] as $k => $mt ) {
|
foreach ( $tabht[$key] as $k => $mt ) {
|
||||||
$companystatic->id = $tabcompany[$key]['id'];
|
$companystatic->id = $tabcompany[$key]['id'];
|
||||||
$companystatic->name = $tabcompany[$key]['name'];
|
$companystatic->name = $tabcompany[$key]['name'];
|
||||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||||
|
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
print $date . $sep;
|
print $date . $sep;
|
||||||
print $purchase_journal . $sep;
|
print $purchase_journal . $sep;
|
||||||
@ -294,7 +294,7 @@ if ($action == 'export_csv') {
|
|||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
@ -309,7 +309,7 @@ if ($action == 'export_csv') {
|
|||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||||
print $date . $sep;
|
print $date . $sep;
|
||||||
print $purchase_journal . $sep;
|
print $purchase_journal . $sep;
|
||||||
@ -326,11 +326,11 @@ if ($action == 'export_csv') {
|
|||||||
// Model Classic Export
|
// Model Classic Export
|
||||||
foreach ( $tabfac as $key => $val ) {
|
foreach ( $tabfac as $key => $val ) {
|
||||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||||
|
|
||||||
$companystatic->id = $tabcompany[$key]['id'];
|
$companystatic->id = $tabcompany[$key]['id'];
|
||||||
$companystatic->name = $tabcompany[$key]['name'];
|
$companystatic->name = $tabcompany[$key]['name'];
|
||||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||||
|
|
||||||
// Product / Service
|
// Product / Service
|
||||||
foreach ( $tabht[$key] as $k => $mt ) {
|
foreach ( $tabht[$key] as $k => $mt ) {
|
||||||
$accountingaccount = new AccountingAccount($db);
|
$accountingaccount = new AccountingAccount($db);
|
||||||
@ -357,7 +357,7 @@ if ($action == 'export_csv') {
|
|||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third party
|
// Third party
|
||||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||||
print '"' . $date . '"' . $sep;
|
print '"' . $date . '"' . $sep;
|
||||||
@ -371,11 +371,11 @@ if ($action == 'export_csv') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
llxHeader('', $langs->trans("PurchasesJournal"));
|
llxHeader('', $langs->trans("PurchasesJournal"));
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
$nom = $langs->trans("PurchasesJournal");
|
$nom = $langs->trans("PurchasesJournal");
|
||||||
$nomlink = '';
|
$nomlink = '';
|
||||||
$periodlink = '';
|
$periodlink = '';
|
||||||
@ -387,16 +387,16 @@ if ($action == 'export_csv') {
|
|||||||
} else {
|
} else {
|
||||||
$description .= $langs->trans("DepositsAreIncluded");
|
$description .= $langs->trans("DepositsAreIncluded");
|
||||||
}
|
}
|
||||||
|
|
||||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||||
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
|
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
|
||||||
'action' => ''
|
'action' => ''
|
||||||
));
|
));
|
||||||
|
|
||||||
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
||||||
|
|
||||||
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||||
|
|
||||||
print '
|
print '
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function launch_export() {
|
function launch_export() {
|
||||||
@ -410,12 +410,12 @@ if ($action == 'export_csv') {
|
|||||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||||
}
|
}
|
||||||
</script>';
|
</script>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show result array
|
* Show result array
|
||||||
*/
|
*/
|
||||||
print '<br><br>';
|
print '<br><br>';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
print "<table class=\"noborder\" width=\"100%\">";
|
||||||
print "<tr class=\"liste_titre\">";
|
print "<tr class=\"liste_titre\">";
|
||||||
@ -425,25 +425,25 @@ if ($action == 'export_csv') {
|
|||||||
print "<td>" . $langs->trans("Account") . "</td>";
|
print "<td>" . $langs->trans("Account") . "</td>";
|
||||||
print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$var = true;
|
$var = true;
|
||||||
$r = '';
|
$r = '';
|
||||||
|
|
||||||
$invoicestatic = new FactureFournisseur($db);
|
$invoicestatic = new FactureFournisseur($db);
|
||||||
|
|
||||||
foreach ( $tabfac as $key => $val ) {
|
foreach ( $tabfac as $key => $val ) {
|
||||||
$invoicestatic->id = $key;
|
$invoicestatic->id = $key;
|
||||||
$invoicestatic->ref = $val["ref"];
|
$invoicestatic->ref = $val["ref"];
|
||||||
$invoicestatic->type = $val["type"];
|
$invoicestatic->type = $val["type"];
|
||||||
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
|
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
|
||||||
|
|
||||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||||
|
|
||||||
// Product / Service
|
// Product / Service
|
||||||
foreach ( $tabht[$key] as $k => $mt ) {
|
foreach ( $tabht[$key] as $k => $mt ) {
|
||||||
$accountingaccount = new AccountingAccount($db);
|
$accountingaccount = new AccountingAccount($db);
|
||||||
$accountingaccount->fetch(null, $k);
|
$accountingaccount->fetch(null, $k);
|
||||||
|
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
print "<tr " . $bc[$var] . " >";
|
print "<tr " . $bc[$var] . " >";
|
||||||
print "<td>" . $date . "</td>";
|
print "<td>" . $date . "</td>";
|
||||||
@ -468,7 +468,7 @@ if ($action == 'export_csv') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "<tr " . $bc[$var] . ">";
|
print "<tr " . $bc[$var] . ">";
|
||||||
|
|
||||||
// Third party
|
// Third party
|
||||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||||
print "<td>" . $date . "</td>";
|
print "<td>" . $date . "</td>";
|
||||||
@ -483,12 +483,12 @@ if ($action == 'export_csv') {
|
|||||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||||
}
|
}
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
|
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,16 +119,16 @@ if ($result) {
|
|||||||
$tabtva = array ();
|
$tabtva = array ();
|
||||||
$tabttc = array ();
|
$tabttc = array ();
|
||||||
$tabcompany = array ();
|
$tabcompany = array ();
|
||||||
|
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while ( $i < $num ) {
|
while ( $i < $num ) {
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
// les variables
|
// les variables
|
||||||
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
|
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
|
||||||
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
|
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
|
||||||
|
|
||||||
$compta_prod = $obj->compte;
|
$compta_prod = $obj->compte;
|
||||||
if (empty($compta_prod)) {
|
if (empty($compta_prod)) {
|
||||||
if ($obj->product_type == 0)
|
if ($obj->product_type == 0)
|
||||||
@ -138,7 +138,7 @@ if ($result) {
|
|||||||
}
|
}
|
||||||
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
|
||||||
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
||||||
|
|
||||||
// Situation invoices handling
|
// Situation invoices handling
|
||||||
$line = new FactureLigne($db);
|
$line = new FactureLigne($db);
|
||||||
$line->fetch($obj->rowid);
|
$line->fetch($obj->rowid);
|
||||||
@ -153,7 +153,7 @@ if ($result) {
|
|||||||
} else {
|
} else {
|
||||||
$situation_ratio = 1;
|
$situation_ratio = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoice lines
|
// Invoice lines
|
||||||
$tabfac[$obj->rowid]["date"] = $obj->df;
|
$tabfac[$obj->rowid]["date"] = $obj->df;
|
||||||
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
|
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
|
||||||
@ -172,9 +172,9 @@ if ($result) {
|
|||||||
$tabcompany[$obj->rowid] = array (
|
$tabcompany[$obj->rowid] = array (
|
||||||
'id' => $obj->socid,
|
'id' => $obj->socid,
|
||||||
'name' => $obj->name,
|
'name' => $obj->name,
|
||||||
'code_client' => $obj->code_compta
|
'code_client' => $obj->code_compta
|
||||||
);
|
);
|
||||||
|
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -190,7 +190,7 @@ if ($result) {
|
|||||||
if ($action == 'writebookkeeping') {
|
if ($action == 'writebookkeeping') {
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
foreach ( $tabfac as $key => $val ) {
|
foreach ( $tabfac as $key => $val ) {
|
||||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||||
$bookkeeping = new BookKeeping($db);
|
$bookkeeping = new BookKeeping($db);
|
||||||
@ -209,14 +209,14 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product / Service
|
// Product / Service
|
||||||
foreach ( $tabht[$key] as $k => $mt ) {
|
foreach ( $tabht[$key] as $k => $mt ) {
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
@ -239,16 +239,16 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
// var_dump($tabtva);
|
// var_dump($tabtva);
|
||||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||||
@ -269,16 +269,16 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error)) {
|
if (empty($error)) {
|
||||||
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
||||||
}
|
}
|
||||||
@ -288,23 +288,23 @@ if ($action == 'writebookkeeping') {
|
|||||||
if ($action == 'export_csv') {
|
if ($action == 'export_csv') {
|
||||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||||
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||||
|
|
||||||
$companystatic = new Client($db);
|
$companystatic = new Client($db);
|
||||||
|
|
||||||
// Model Cegid Expert Export
|
// Model Cegid Expert Export
|
||||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
||||||
{
|
{
|
||||||
$sep = ";";
|
$sep = ";";
|
||||||
|
|
||||||
foreach ( $tabfac as $key => $val ) {
|
foreach ( $tabfac as $key => $val ) {
|
||||||
$companystatic->id = $tabcompany[$key]['id'];
|
$companystatic->id = $tabcompany[$key]['id'];
|
||||||
$companystatic->name = $tabcompany[$key]['name'];
|
$companystatic->name = $tabcompany[$key]['name'];
|
||||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||||
|
|
||||||
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
||||||
|
|
||||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||||
print $date . $sep;
|
print $date . $sep;
|
||||||
print $sell_journal . $sep;
|
print $sell_journal . $sep;
|
||||||
@ -316,7 +316,7 @@ if ($action == 'export_csv') {
|
|||||||
print $val["ref"];
|
print $val["ref"];
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product / Service
|
// Product / Service
|
||||||
foreach ( $tabht[$key] as $k => $mt ) {
|
foreach ( $tabht[$key] as $k => $mt ) {
|
||||||
$accountingaccount_static = new AccountingAccount($db);
|
$accountingaccount_static = new AccountingAccount($db);
|
||||||
@ -332,7 +332,7 @@ if ($action == 'export_csv') {
|
|||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TVA
|
// TVA
|
||||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
@ -354,9 +354,9 @@ if ($action == 'export_csv') {
|
|||||||
$companystatic->id = $tabcompany[$key]['id'];
|
$companystatic->id = $tabcompany[$key]['id'];
|
||||||
$companystatic->name = $tabcompany[$key]['name'];
|
$companystatic->name = $tabcompany[$key]['name'];
|
||||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||||
|
|
||||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||||
|
|
||||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||||
print '"' . $date . '"' . $sep;
|
print '"' . $date . '"' . $sep;
|
||||||
print '"' . $val["ref"] . '"' . $sep;
|
print '"' . $val["ref"] . '"' . $sep;
|
||||||
@ -366,12 +366,12 @@ if ($action == 'export_csv') {
|
|||||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product / Service
|
// Product / Service
|
||||||
foreach ( $tabht[$key] as $k => $mt ) {
|
foreach ( $tabht[$key] as $k => $mt ) {
|
||||||
$accountingaccount = new AccountingAccount($db);
|
$accountingaccount = new AccountingAccount($db);
|
||||||
$accountingaccount->fetch(null, $k);
|
$accountingaccount->fetch(null, $k);
|
||||||
|
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
print '"' . $date . '"' . $sep;
|
print '"' . $date . '"' . $sep;
|
||||||
print '"' . $val["ref"] . '"' . $sep;
|
print '"' . $val["ref"] . '"' . $sep;
|
||||||
@ -382,7 +382,7 @@ if ($action == 'export_csv') {
|
|||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
@ -398,11 +398,11 @@ if ($action == 'export_csv') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
llxHeader('', $langs->trans("SellsJournal"));
|
llxHeader('', $langs->trans("SellsJournal"));
|
||||||
|
|
||||||
$nom = $langs->trans("SellsJournal");
|
$nom = $langs->trans("SellsJournal");
|
||||||
$nomlink = '';
|
$nomlink = '';
|
||||||
$periodlink = '';
|
$periodlink = '';
|
||||||
@ -415,13 +415,13 @@ if ($action == 'export_csv') {
|
|||||||
$description .= $langs->trans("DepositsAreIncluded");
|
$description .= $langs->trans("DepositsAreIncluded");
|
||||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||||
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
|
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
|
||||||
'action' => ''
|
'action' => ''
|
||||||
));
|
));
|
||||||
|
|
||||||
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
||||||
|
|
||||||
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||||
|
|
||||||
print '
|
print '
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function launch_export() {
|
function launch_export() {
|
||||||
@ -435,12 +435,12 @@ if ($action == 'export_csv') {
|
|||||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||||
}
|
}
|
||||||
</script>';
|
</script>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show result array
|
* Show result array
|
||||||
*/
|
*/
|
||||||
print '<br><br>';
|
print '<br><br>';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
print "<table class=\"noborder\" width=\"100%\">";
|
||||||
print "<tr class=\"liste_titre\">";
|
print "<tr class=\"liste_titre\">";
|
||||||
@ -451,20 +451,20 @@ if ($action == 'export_csv') {
|
|||||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$var = true;
|
$var = true;
|
||||||
$r = '';
|
$r = '';
|
||||||
|
|
||||||
$invoicestatic = new Facture($db);
|
$invoicestatic = new Facture($db);
|
||||||
$companystatic = new Client($db);
|
$companystatic = new Client($db);
|
||||||
|
|
||||||
foreach ( $tabfac as $key => $val ) {
|
foreach ( $tabfac as $key => $val ) {
|
||||||
$invoicestatic->id = $key;
|
$invoicestatic->id = $key;
|
||||||
$invoicestatic->ref = $val["ref"];
|
$invoicestatic->ref = $val["ref"];
|
||||||
$invoicestatic->type = $val["type"];
|
$invoicestatic->type = $val["type"];
|
||||||
|
|
||||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||||
|
|
||||||
// Third party
|
// Third party
|
||||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||||
print "<tr " . $bc[$var] . ">";
|
print "<tr " . $bc[$var] . ">";
|
||||||
@ -480,12 +480,12 @@ if ($action == 'export_csv') {
|
|||||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||||
}
|
}
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
|
|
||||||
// Product / Service
|
// Product / Service
|
||||||
foreach ( $tabht[$key] as $k => $mt ) {
|
foreach ( $tabht[$key] as $k => $mt ) {
|
||||||
$accountingaccount = new AccountingAccount($db);
|
$accountingaccount = new AccountingAccount($db);
|
||||||
$accountingaccount->fetch(null, $k);
|
$accountingaccount->fetch(null, $k);
|
||||||
|
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
print "<tr " . $bc[$var] . ">";
|
print "<tr " . $bc[$var] . ">";
|
||||||
print "<td>" . $date . "</td>";
|
print "<td>" . $date . "</td>";
|
||||||
@ -497,7 +497,7 @@ if ($action == 'export_csv') {
|
|||||||
print "</tr>";
|
print "</tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
@ -511,12 +511,12 @@ if ($action == 'export_csv') {
|
|||||||
print "</tr>";
|
print "</tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user