|
@@ -119,16 +119,16 @@ if ($result) {
|
|
|
$tabtva = array ();
|
|
|
$tabttc = array ();
|
|
|
$tabcompany = array ();
|
|
|
-
|
|
|
+
|
|
|
$num = $db->num_rows($result);
|
|
|
$i = 0;
|
|
|
-
|
|
|
+
|
|
|
while ( $i < $num ) {
|
|
|
$obj = $db->fetch_object($result);
|
|
|
// les variables
|
|
|
$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_prod = $obj->compte;
|
|
|
if (empty($compta_prod)) {
|
|
|
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");
|
|
|
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
|
|
|
-
|
|
|
+
|
|
|
// Situation invoices handling
|
|
|
$line = new FactureLigne($db);
|
|
|
$line->fetch($obj->rowid);
|
|
@@ -153,7 +153,7 @@ if ($result) {
|
|
|
} else {
|
|
|
$situation_ratio = 1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Invoice lines
|
|
|
$tabfac[$obj->rowid]["date"] = $obj->df;
|
|
|
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
|
|
@@ -172,9 +172,9 @@ if ($result) {
|
|
|
$tabcompany[$obj->rowid] = array (
|
|
|
'id' => $obj->socid,
|
|
|
'name' => $obj->name,
|
|
|
- 'code_client' => $obj->code_compta
|
|
|
+ 'code_client' => $obj->code_compta
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
$i ++;
|
|
|
}
|
|
|
} else {
|
|
@@ -190,7 +190,7 @@ if ($result) {
|
|
|
if ($action == 'writebookkeeping') {
|
|
|
$now = dol_now();
|
|
|
$error = 0;
|
|
|
-
|
|
|
+
|
|
|
foreach ( $tabfac as $key => $val ) {
|
|
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
|
|
$bookkeeping = new BookKeeping($db);
|
|
@@ -209,14 +209,14 @@ if ($action == 'writebookkeeping') {
|
|
|
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
|
|
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
|
|
$bookkeeping->fk_user_author = $user->id;
|
|
|
-
|
|
|
+
|
|
|
$result = $bookkeeping->create($user);
|
|
|
if ($result < 0) {
|
|
|
$error ++;
|
|
|
- setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Product / Service
|
|
|
foreach ( $tabht[$key] as $k => $mt ) {
|
|
|
if ($mt) {
|
|
@@ -239,16 +239,16 @@ if ($action == 'writebookkeeping') {
|
|
|
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
|
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
|
|
$bookkeeping->fk_user_author = $user->id;
|
|
|
-
|
|
|
+
|
|
|
$result = $bookkeeping->create($user);
|
|
|
if ($result < 0) {
|
|
|
$error ++;
|
|
|
- setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// VAT
|
|
|
// var_dump($tabtva);
|
|
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
|
@@ -269,16 +269,16 @@ if ($action == 'writebookkeeping') {
|
|
|
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
|
|
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
|
|
$bookkeeping->fk_user_author = $user->id;
|
|
|
-
|
|
|
+
|
|
|
$result = $bookkeeping->create($user);
|
|
|
if ($result < 0) {
|
|
|
$error ++;
|
|
|
- setEventMessages($object->error, $object->errors, 'errors');
|
|
|
+ setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (empty($error)) {
|
|
|
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
|
|
|
}
|
|
@@ -288,23 +288,23 @@ if ($action == 'writebookkeeping') {
|
|
|
if ($action == 'export_csv') {
|
|
|
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
|
|
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
|
|
-
|
|
|
+
|
|
|
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
|
|
-
|
|
|
+
|
|
|
$companystatic = new Client($db);
|
|
|
-
|
|
|
+
|
|
|
// Model Cegid Expert Export
|
|
|
- if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
|
|
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
|
|
{
|
|
|
$sep = ";";
|
|
|
-
|
|
|
+
|
|
|
foreach ( $tabfac as $key => $val ) {
|
|
|
$companystatic->id = $tabcompany[$key]['id'];
|
|
|
$companystatic->name = $tabcompany[$key]['name'];
|
|
|
$companystatic->client = $tabcompany[$key]['code_client'];
|
|
|
-
|
|
|
+
|
|
|
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
|
|
-
|
|
|
+
|
|
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
|
|
print $date . $sep;
|
|
|
print $sell_journal . $sep;
|
|
@@ -316,7 +316,7 @@ if ($action == 'export_csv') {
|
|
|
print $val["ref"];
|
|
|
print "\n";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Product / Service
|
|
|
foreach ( $tabht[$key] as $k => $mt ) {
|
|
|
$accountingaccount_static = new AccountingAccount($db);
|
|
@@ -332,7 +332,7 @@ if ($action == 'export_csv') {
|
|
|
print "\n";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// TVA
|
|
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
|
|
if ($mt) {
|
|
@@ -354,9 +354,9 @@ if ($action == 'export_csv') {
|
|
|
$companystatic->id = $tabcompany[$key]['id'];
|
|
|
$companystatic->name = $tabcompany[$key]['name'];
|
|
|
$companystatic->client = $tabcompany[$key]['code_client'];
|
|
|
-
|
|
|
+
|
|
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
|
|
-
|
|
|
+
|
|
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
|
|
print '"' . $date . '"' . $sep;
|
|
|
print '"' . $val["ref"] . '"' . $sep;
|
|
@@ -366,12 +366,12 @@ if ($action == 'export_csv') {
|
|
|
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
|
|
print "\n";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Product / Service
|
|
|
foreach ( $tabht[$key] as $k => $mt ) {
|
|
|
$accountingaccount = new AccountingAccount($db);
|
|
|
$accountingaccount->fetch(null, $k);
|
|
|
-
|
|
|
+
|
|
|
if ($mt) {
|
|
|
print '"' . $date . '"' . $sep;
|
|
|
print '"' . $val["ref"] . '"' . $sep;
|
|
@@ -382,7 +382,7 @@ if ($action == 'export_csv') {
|
|
|
print "\n";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// VAT
|
|
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
|
|
if ($mt) {
|
|
@@ -398,11 +398,11 @@ if ($action == 'export_csv') {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
-
|
|
|
+
|
|
|
$form = new Form($db);
|
|
|
-
|
|
|
+
|
|
|
llxHeader('', $langs->trans("SellsJournal"));
|
|
|
-
|
|
|
+
|
|
|
$nom = $langs->trans("SellsJournal");
|
|
|
$nomlink = '';
|
|
|
$periodlink = '';
|
|
@@ -415,13 +415,13 @@ if ($action == 'export_csv') {
|
|
|
$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);
|
|
|
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" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
|
|
-
|
|
|
+
|
|
|
print '
|
|
|
<script type="text/javascript">
|
|
|
function launch_export() {
|
|
@@ -435,12 +435,12 @@ if ($action == 'export_csv') {
|
|
|
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
|
|
}
|
|
|
</script>';
|
|
|
-
|
|
|
+
|
|
|
/*
|
|
|
* Show result array
|
|
|
*/
|
|
|
print '<br><br>';
|
|
|
-
|
|
|
+
|
|
|
$i = 0;
|
|
|
print "<table class=\"noborder\" width=\"100%\">";
|
|
|
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("Credit") . "</td>";
|
|
|
print "</tr>\n";
|
|
|
-
|
|
|
+
|
|
|
$var = true;
|
|
|
$r = '';
|
|
|
-
|
|
|
+
|
|
|
$invoicestatic = new Facture($db);
|
|
|
$companystatic = new Client($db);
|
|
|
-
|
|
|
+
|
|
|
foreach ( $tabfac as $key => $val ) {
|
|
|
$invoicestatic->id = $key;
|
|
|
$invoicestatic->ref = $val["ref"];
|
|
|
$invoicestatic->type = $val["type"];
|
|
|
-
|
|
|
+
|
|
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
|
|
-
|
|
|
+
|
|
|
// Third party
|
|
|
foreach ( $tabttc[$key] as $k => $mt ) {
|
|
|
print "<tr " . $bc[$var] . ">";
|
|
@@ -480,12 +480,12 @@ if ($action == 'export_csv') {
|
|
|
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
|
|
}
|
|
|
print "</tr>";
|
|
|
-
|
|
|
+
|
|
|
// Product / Service
|
|
|
foreach ( $tabht[$key] as $k => $mt ) {
|
|
|
$accountingaccount = new AccountingAccount($db);
|
|
|
$accountingaccount->fetch(null, $k);
|
|
|
-
|
|
|
+
|
|
|
if ($mt) {
|
|
|
print "<tr " . $bc[$var] . ">";
|
|
|
print "<td>" . $date . "</td>";
|
|
@@ -497,7 +497,7 @@ if ($action == 'export_csv') {
|
|
|
print "</tr>";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// VAT
|
|
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
|
|
if ($mt) {
|
|
@@ -511,12 +511,12 @@ if ($action == 'export_csv') {
|
|
|
print "</tr>";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$var = ! $var;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
print "</table>";
|
|
|
-
|
|
|
+
|
|
|
// End of page
|
|
|
llxFooter();
|
|
|
}
|