diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index f606cc48868..a7e20f22b74 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -101,13 +101,14 @@ $formaccounting = new FormAccounting($db); if (!empty($id)) { $sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,"; - $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,"; + $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, l.fk_code_ventilation,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label,"; if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " ppe.accountancy_code_sell as code_sell,"; } else { $sql .= " p.accountancy_code_sell as code_sell,"; } - $sql .= " l.fk_code_ventilation, aa.account_number, aa.label"; + $sql .= " aa.account_number, aa.label"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { @@ -139,18 +140,23 @@ if (!empty($id)) { print ''; - // Ref facture + // Ref invoice print ''; $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + + print ''; + print ''; + + print ''; + print '
'.$langs->trans("Invoice").''.$facture_static->getNomUrl(1).'
'.$langs->trans("Line").''.nl2br($objp->description).'
'.$langs->trans("Account").''; + print '
'.$langs->trans("Description").''.dolPrintHTML($objp->description).'
'.$langs->trans("ProductLabel").''.dol_trunc($objp->product_label, 24).'
'.$langs->trans("Account").''; print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; print dol_get_fiche_end(); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index b1b82d35735..9594f4aa722 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -17,7 +17,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ /** @@ -40,17 +39,6 @@ $langs->loadLangs(array("compta", "bills", "other", "accountancy")); $validatemonth = GETPOSTINT('validatemonth'); $validateyear = GETPOSTINT('validateyear'); -// Security check -if (!isModEnabled('accounting')) { - accessforbidden(); -} -if ($user->socid > 0) { - accessforbidden(); -} -if (!$user->hasRight('accounting', 'bind', 'write')) { - accessforbidden(); -} - $accountingAccount = new AccountingAccount($db); $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); @@ -84,7 +72,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (!$user->hasRight('accounting', 'mouvements', 'lire')) { +if (!$user->hasRight('accounting', 'bind', 'write')) { accessforbidden(); } @@ -259,7 +247,7 @@ if ($action == 'validatehistory' && $user->hasRight('accounting', 'bind', 'write } if ($suggestedid > 0) { - $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sqlupdate = "UPDATE ".$db->prefix()."facturedet"; $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid); $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $facture_static_det->id); @@ -320,7 +308,7 @@ if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) { $y = $year_current; -$buttonbind = ''.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind); //print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -362,8 +350,9 @@ for ($i = 1; $i <= 12; $i++) { $j -= 12; } $sql .= " SUM(".$db->ifsql("MONTH(f.datef) = ".((string) $j), "fd.total_ht", "0").") AS month".str_pad((string) $j, 2, "0", STR_PAD_LEFT).","; + $sql .= " SUM(".$db->ifsql("MONTH(f.datef) = ".((string) $j), "1", "0").") AS nbmonth".str_pad((string) $j, 2, "0", STR_PAD_LEFT).","; } -$sql .= " SUM(fd.total_ht) as total"; +$sql .= " SUM(fd.total_ht) as total, COUNT(fd.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; @@ -420,6 +409,7 @@ if ($resql) { print $row[1]; } print ''; + for ($i = 2; $i <= 13; $i++) { $cursormonth = (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + $i - 2); if ($cursormonth > 12) { @@ -428,17 +418,19 @@ if ($resql) { $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); - print ''; - print price($row[$i]); + print ''; + print price($row[2*$i - 2]); // Add link to make binding - if (!empty(price2num($row[$i]))) { + if (!empty(price2num($row[2*$i - 2])) || !empty($row[2*$i - 1])) { print ''; print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad((string) $cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); print ''; } print ''; } - print ''.price($row[14]).''; + + print ''.price($row[26]).''; + print ''; } $db->free($resql); @@ -584,7 +576,7 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa print '
'; print ''; - print ''; + print ''; for ($i = 1; $i <= 12; $i++) { $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; if ($j > 12) { diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index f3dbc54f78a..174ff4039da 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -77,17 +77,17 @@ if (!$user->hasRight('accounting', 'bind', 'write')) { */ if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) { - // Clean database + // Clean database by removing binding done on non existing or no more existing accounts $db->begin(); - $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql1 = "UPDATE ".$db->prefix()."expensereport_det as erd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE erd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; - $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' FROM '.$db->prefix().'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.$db->prefix().'accounting_system as syst'; $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.((int) getDolGlobalInt('CHARTOFACCOUNTS')).' AND accnt.entity = '.((int) $conf->entity).')'; - $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'expensereport WHERE entity = '.((int) $conf->entity).')'; - $sql1 .= ' AND fk_code_ventilation <> 0'; + $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.$db->prefix().'expensereport WHERE entity = '.((int) $conf->entity).')'; + $sql1 .= " AND fk_code_ventilation <> 0"; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); if (!$resql1) { @@ -194,7 +194,7 @@ print '
'; $y = $year_current; -$buttonbind = ''.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind); @@ -238,8 +238,9 @@ for ($i = 1; $i <= 12; $i++) { $j -= 12; } $sql .= " SUM(".$db->ifsql("MONTH(er.date_debut) = ".((int) $j), "erd.total_ht", "0").") AS month".str_pad((string) $j, 2, "0", STR_PAD_LEFT).","; + $sql .= " SUM(".$db->ifsql("MONTH(er.date_debut) = ".((string) $j), "1", "0").") AS nbmonth".str_pad((string) $j, 2, "0", STR_PAD_LEFT).","; } -$sql .= " SUM(erd.total_ht) as total"; +$sql .= " SUM(erd.total_ht) as total, COUNT(erd.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; @@ -294,17 +295,17 @@ if ($resql) { $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); - print ''; } - print ''; + print ''; print ''; } $db->free($resql); @@ -371,14 +372,12 @@ if ($resql) { while ($row = $db->fetch_row($resql)) { print ''; - print ''; - //print ''; } - print ''; + print ''; print ''; } $db->free($resql);
'.$langs->trans("TotalVente").'
'.$langs->trans("TotalVente").''; - print price($row[$i]); + print ''; + print price($row[2*$i - 2]); // Add link to make binding - if (!empty(price2num($row[$i]))) { + if (!empty(price2num($row[2*$i - 2])) || !empty($row[2*$i - 1])) { print ''; print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad((string) $cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); print ''; } print ''.price($row[14]).''.price($row[26]).'
'; + print ''; if ($row[0] == 'tobind') { //print ''.$langs->trans("Unknown").''; } else { print length_accountg($row[0]).' - '; } - //print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); } else { diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 153c86b7c6c..03332e9a862 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -141,20 +141,23 @@ if (!empty($id)) { print ''; - // ref invoice + // Ref invoice print ''; $facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->id = $objp->facid; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + + print ''; + print ''; + + print ''; + print '
'.$langs->trans("BillsSuppliers").''.$facturefournisseur_static->getNomUrl(1).'
'.$langs->trans("Line").''.stripslashes(nl2br($objp->description)).'
'.$langs->trans("ProductLabel").''.dol_trunc($objp->product_label, 24).'
'.$langs->trans("Account").''; + print '
'.$langs->trans("Description").''.dolPrintHTML($objp->description).'
'.$langs->trans("ProductLabel").''.dol_trunc($objp->product_label, 24).'
'.$langs->trans("Account").''; print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; print dol_get_fiche_end(); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index bb9572bc879..19064b24d6d 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -81,7 +81,7 @@ if (!$user->hasRight('accounting', 'bind', 'write')) { */ if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) { - // Clean database + // Clean database by removing binding done on non existing or no more existing accounts $db->begin(); $sql1 = "UPDATE ".$db->prefix()."facture_fourn_det as fd"; $sql1 .= " SET fk_code_ventilation = 0"; @@ -178,31 +178,31 @@ if ($action == 'validatehistory' && $user->hasRight('accounting', 'bind', 'write while ($i < min($num_lines, 10000)) { // No more than 10000 at once $objp = $db->fetch_object($result); - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta_client = $objp->code_compta_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->country_code = $objp->country_code; - $thirdpartystatic->tva_intra = $objp->tva_intra; + $thirdpartystatic->id = !empty($objp->socid) ? $objp->socid : 0; + $thirdpartystatic->name = !empty($objp->name) ? $objp->name : ""; + $thirdpartystatic->client = !empty($objp->client) ? $objp->client : ""; + $thirdpartystatic->fournisseur = !empty($objp->fournisseur) ? $objp->fournisseur : ""; + $thirdpartystatic->code_client = !empty($objp->code_client) ? $objp->code_client : ""; + $thirdpartystatic->code_compta_client = !empty($objp->code_compta_client) ? $objp->code_compta_client : ""; + $thirdpartystatic->code_fournisseur = !empty($objp->code_fournisseur) ? $objp->code_fournisseur : ""; + $thirdpartystatic->code_compta_fournisseur = !empty($objp->code_compta_fournisseur) ? $objp->code_compta_fournisseur : ""; + $thirdpartystatic->email = !empty($objp->email) ? $objp->email : ""; + $thirdpartystatic->country_code = !empty($objp->country_code) ? $objp->country_code : ""; + $thirdpartystatic->tva_intra = !empty($objp->tva_intra) ? $objp->tva_intra : ""; $thirdpartystatic->code_compta_product = $objp->company_code_buy; // The accounting account for product stored on thirdparty object (for level3 suggestion) $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; $product_static->type = $objp->type; $product_static->label = $objp->product_label; - $product_static->status = $objp->status; - $product_static->status_buy = $objp->status_buy; + $product_static->status = !empty($objp->status) ? $objp->status : 0; + $product_static->status_buy = !empty($objp->status_buy) ? $objp->status_buy : 0; $product_static->accountancy_code_sell = $objp->code_sell; $product_static->accountancy_code_sell_intra = $objp->code_sell_intra; $product_static->accountancy_code_sell_export = $objp->code_sell_export; - $product_static->accountancy_code_buy = $objp->code_buy; - $product_static->accountancy_code_buy_intra = $objp->code_buy_intra; - $product_static->accountancy_code_buy_export = $objp->code_buy_export; + $product_static->accountancy_code_buy = !empty($objp->code_buy) ? $objp->code_buy : ""; + $product_static->accountancy_code_buy_intra = !empty($objp->code_buy_intra) ? $objp->code_buy_intra : ""; + $product_static->accountancy_code_buy_export = !empty($objp->code_buy_export) ? $objp->code_buy_export : ""; $product_static->tva_tx = $objp->tva_tx_prod; $facture_static->ref = $objp->ref; @@ -301,7 +301,7 @@ print '
'; $y = $year_current; -$buttonbind = ''.img_picto('', 'link', 'class="paddingright fa-color-unset smallpaddingimp"').$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind); @@ -344,8 +344,9 @@ for ($i = 1; $i <= 12; $i++) { $j -= 12; } $sql .= " SUM(".$db->ifsql("MONTH(ff.datef) = ".((int) $j), "ffd.total_ht", "0").") AS month".str_pad((string) $j, 2, "0", STR_PAD_LEFT).","; + $sql .= " SUM(".$db->ifsql("MONTH(ff.datef) = ".((string) $j), "1", "0").") AS nbmonth".str_pad((string) $j, 2, "0", STR_PAD_LEFT).","; } -$sql .= " SUM(ffd.total_ht) as total"; +$sql .= " SUM(ffd.total_ht) as total, COUNT(ffd.rowid) as nb"; $sql .= " FROM ".$db->prefix()."facture_fourn_det as ffd"; $sql .= " LEFT JOIN ".$db->prefix()."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; $sql .= " LEFT JOIN ".$db->prefix()."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; @@ -405,17 +406,17 @@ if ($resql) { $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); - print '
'; - print price($row[$i]); + print ''; + print price($row[2*$i - 2]); // Add link to make binding - if (!empty(price2num($row[$i]))) { + if (!empty(price2num($row[2*$i - 2])) || !empty($row[2*$i - 1])) { print ''; print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad((string) $cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); print ''; } print ''.price($row[14]).''.price($row[26]).'