diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 28333b3edee..3c47498c52e 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -322,10 +322,22 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) print ''; - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + print ''; + } + print ''; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 0dc1798ef57..0b43e99b1d8 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -198,7 +198,8 @@ if (! $conf->use_javascript_ajax) { $listmodelcsv = array ( '1' => $langs->trans("Modelcsv_normal"), '2' => $langs->trans("Modelcsv_CEGID"), - '3' => $langs->trans("Modelcsv_COALA") + '3' => $langs->trans("Modelcsv_COALA"), + '4' => $langs->trans("Modelcsv_bob50") ); print $form->selectarray("modelcsv", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0); diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 16027a42af4..3e4b69d6624 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * * 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 @@ -106,81 +106,38 @@ if (! empty($search_accountancy_code_end)) { if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = 'bookkepping'; - + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - - $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); + + $result = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + foreach ( $object->lines as $line ) { - + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; - // Model Cegid Expert Export - $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $date . $sep; - print $line->code_journal . $sep; - print length_accountg($line->numero_compte) . $sep; - print ' ' . $sep; - print $line->sens . $sep; - print price($line->montant) . $sep; - print dol_trunc($line->label_compte, 32) . $sep; - print $line->doc_ref . $sep; - - /*print $line->piece_num . $sep; - print length_accounta($line->code_tiers) . $sep; - print . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep;*/ - - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - - // Std export - $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); - print $date . $sep; - print $line->doc_ref . $sep; - print length_accounta($line->numero_compte) . $sep; - print length_accountg($line->code_tiers) . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - - /*print $line->piece_num . $sep; - print $line->label_compte . $sep; - print price($line->montant) . $sep; - print $line->sens . $sep;*/ - print $line->code_journal . $sep; - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { - - // Coala export - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $sep; - print $line->code_journal . $sep; - print length_accounta($line->numero_compte) . $sep; - print $line->piece_num . $sep; - print $line->doc_ref . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print 'E' . $sep; - print length_accountg($line->code_tiers) . $sep; - print "\n"; } + print length_accountg($line->numero_compte) . $sep; + print $line->debit . $sep; + print $line->credit . $sep; + print $line->debit . $sep; + print $line->credit - $line->debit . $sep; + print "\n"; } -} +} else { - + $title_page = $langs->trans("AccountBalance") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); - + llxHeader('', $title_page); - + /* * List */ - + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); @@ -188,27 +145,27 @@ else { setEventMessages($object->error, $object->errors, 'errors'); } } - + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); - + print '
'; print '
' . "\n"; print '
'; - + print '
'; - + print '
'; print $langs->trans('DateStart') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print $langs->trans('DateEnd') . ': '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print '
'; - + print ''; print ''; print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); @@ -217,7 +174,7 @@ else { print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; - + print ''; print ''; - + print ''; print ''; print ''; - + print ''; - + print ''; - + $var = True; - + $total_debit = 0; $total_credit = 0; - + foreach ( $object->lines as $line ) { $var = ! $var; - + $total_debit += $line->debit; $total_credit += $line->credit; - + print ""; - + print ''; print ''; print ''; @@ -260,7 +217,7 @@ else { print ''; print "\n"; } - + print ''; print ''; print ''; print ''; print ''; - + print "
'; print $langs->trans('From'); @@ -226,32 +183,32 @@ else { print $langs->trans('To'); print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print '   '; print ''; print ' '; print ''; print '
' . length_accountg($line->numero_compte) . '' . price($line->debit) . '' . price($line->credit) . '
'; @@ -272,10 +229,10 @@ else { print '' . price($total_credit - $total_debit) . '
"; print '
'; - + llxFooter(); } $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 387df40122c..515736580f8 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * * 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 @@ -182,9 +182,9 @@ if (! empty($search_mvt_num)) { * Action */ if ($action == 'delbookkeeping') { - + $import_key = GETPOST('importkey', 'alpha'); - + if (! empty($import_key)) { $result = $object->deleteByImportkey($import_key); if ($result < 0) { @@ -194,9 +194,9 @@ if ($action == 'delbookkeeping') { exit(); } } elseif ($action == 'delbookkeepingyearconfirm') { - + $delyear = GETPOST('delyear', 'int'); - + if (! empty($delyear)) { $result = $object->deleteByYear($delyear); if ($result < 0) { @@ -206,34 +206,30 @@ if ($action == 'delbookkeeping') { exit(); } } elseif ($action == 'delmouvconfirm') { - + $mvt_num = GETPOST('mvt_num', 'int'); - + if (! empty($mvt_num)) { $result = $object->deleteMvtNum($mvt_num); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - // if (!empty($options)) { - // Header("Location: list.php?".urldecode($options)); - // } else { Header("Location: list.php"); - // } exit(); } } elseif ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = 'bookkepping'; - + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - + $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + foreach ( $object->lines as $line ) { - + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; // Model Cegid Expert Export @@ -246,16 +242,9 @@ if ($action == 'delbookkeeping') { print price($line->montant) . $sep; print dol_trunc($line->label_compte, 32) . $sep; print $line->doc_ref . $sep; - - /*print $line->piece_num . $sep; - print length_accounta($line->code_tiers) . $sep; - print . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep;*/ - print "\n"; } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - + // Std export $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); print $date . $sep; @@ -264,15 +253,10 @@ if ($action == 'delbookkeeping') { print length_accounta($line->code_tiers) . $sep; print price($line->debit) . $sep; print price($line->credit) . $sep; - - /*print $line->piece_num . $sep; - print $line->label_compte . $sep; - print price($line->montant) . $sep; - print $line->sens . $sep;*/ print $line->code_journal . $sep; print "\n"; } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { - + // Coala export $date = dol_print_date($line->doc_date, '%d/%m/%Y'); print $date . $sep; @@ -285,23 +269,48 @@ if ($action == 'delbookkeeping') { print 'E' . $sep; print length_accountg($line->code_tiers) . $sep; print "\n"; + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 4) { + + // Bob50 + print $line->piece_num . $sep; + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $sep; + + if (empty($line->code_tiers)) { + print 'G' . $sep; + print length_accounta($line->numero_compte) . $sep; + } else { + if (substr($line->numero_compte,0,3)=='411') { + print 'C' . $sep; + } + if (substr($line->numero_compte,0,3)=='401') { + print 'F' . $sep; + } + print length_accountg($line->code_tiers) . $sep; + + } + + print price($line->debit) . $sep; + print price($line->credit) . $sep; + print dol_trunc($line->label_compte, 32) . $sep; + print "\n"; } } -} +} /* * View */ else { - + $title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); - + llxHeader('', $title_page); - + /* * List */ - + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); @@ -309,78 +318,48 @@ else { setEventMessages($object->error, $object->errors, 'errors'); } } - + $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); print $formconfirm; } if ($action == 'delbookkeepingyear') { - + $form_question = array (); $delyear = GETPOST('delyear'); - + if (empty($delyear)) { $delyear = dol_print_date(dol_now(), '%Y'); } $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - + $form_question['delyear'] = array ( 'name' => 'delyear', 'type' => 'select', 'label' => $langs->trans('DelYear'), 'values' => $year_array, - 'default' => $delyear + 'default' => $delyear ); - + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); print $formconfirm; } - + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); - - /*print '
'; - print ''; - print ''; - - print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey')); - - print '
'; - - print '
';*/ - + print '
'; print '
' . "\n"; print '
'; print ''; - // print '' . $langs->trans("Export") . ''; print '
'; - + print '
'; - - /*print '
'; - print $langs->trans('DateStart') . ': '; - print $form->select_date($search_date_start, 'date_start', 0, 0, 1); - print $langs->trans('DateEnd') . ': '; - print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - print '
'; - print '
'; - print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; - print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; - print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); - print '
'; - print '
'; - print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); - print '
';*/ - + print ''; print ''; print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); @@ -391,12 +370,10 @@ else { print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); - // print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); - // print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; - + print ''; print ''; print ''; @@ -404,61 +381,52 @@ else { print $langs->trans('From') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print '
'; - print $langs->trans('to') . ': '; + print $langs->trans('To') . ': '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - // print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1); print ''; print ''; print ''; - // print ''; print ''; - // print ''; - + print ''; print ''; print ''; - // print ''; - // print ''; print ''; print ''; - + print ''; - + $var = True; - + $total_debit = 0; $total_credit = 0; - + foreach ( $object->lines as $line ) { $var = ! $var; - + $total_debit += $line->debit; $total_credit += $line->credit; - + print ""; - + print ''; print ''; print ''; @@ -467,8 +435,6 @@ else { print ''; print ''; print ''; - // print ''; - // print ''; print ''; print ''; print "\n"; } - + print ''; print ''; print ''; print ''; print ''; - + print "
'; - // print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; print $langs->trans('From'); print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - // print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; print '
'; - print $langs->trans('to'); + print $langs->trans('To'); print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print '
'; - // print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $langs->trans('From'); print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - // print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print '
'; - print $langs->trans('to'); + print $langs->trans('To'); print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); print '
'; print ''; print '    '; print ''; print ' '; print ''; print '
' . $line->piece_num . '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->montant) . '' . $line->sens . '' . $line->code_journal . ''; print '' . img_edit() . ' '; @@ -476,7 +442,7 @@ else { print '
'; @@ -487,10 +453,10 @@ else { print '
"; print '
'; - + llxFooter(); } diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index dfd52ec0f00..10640c1887a 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -74,7 +74,6 @@ if (empty($search_date_start)) { $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); } - if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") @@ -184,13 +183,13 @@ print ''; print '
'; print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; print $formventilation->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, ''); -print $langs->trans('to') . ' ' . $langs->trans('AccountAccounting') . ': '; +print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; print $formventilation->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, ''); print '
'; print '
'; print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $formventilation->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); -print $langs->trans('to') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; +print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $formventilation->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); print '
'; print ""; @@ -257,9 +256,10 @@ print ''; -print ''; print "\n"; @@ -268,7 +268,7 @@ $var = True; foreach ( $object->lines as $line ) { $var = ! $var; - + print ""; print '' . "\n"; print '' . "\n"; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0015dfbf9e9..f4b478b681e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015-*2016 Florian Henry + * Copyright (C) 2015-2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify @@ -1064,6 +1064,7 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -1118,7 +1119,7 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -1147,7 +1148,7 @@ class BookKeeping extends CommonObject } } else { $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::fetch_all_per_mvt " . $this->error, LOG_ERR); + dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); return - 1; } diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 7b4d597fc12..471a329e64c 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -48,6 +48,8 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_country = GETPOST('search_country', 'alpha'); +$search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Getpost Order and column and limit page $sortfield = GETPOST('sortfield', 'alpha'); @@ -68,7 +70,7 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $offset = $limit * $page; if (! $sortfield) - $sortfield = "f.datef, f.facnumber, l.rowid"; + $sortfield = "f.datef, f.facnumber, fd.rowid"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { @@ -94,6 +96,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_country = ''; + $search_tvaintra = ''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -150,14 +154,27 @@ print ''; - + /* * Show result array */ print '

'; - + $i = 0; print "
'; print ''; print ''; -$searchpitco=$form->showFilterAndCheckAddButtons(0); -print $searchpitco; +print ''; +print ''; +print ' '; +print ''; print '
' . $line->piece_num . '' . $line->doc_type . '
"; print ""; @@ -425,31 +440,39 @@ if ($action == 'export_csv') { print ""; print ""; print "\n"; - + $var = true; $r = ''; - + $invoicestatic = new FactureFournisseur($db); - + foreach ( $tabfac as $key => $val ) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; + + $invoicestatic->ref = $val["refsologest"]; + $invoicestatic->refsupplier = $val["refsuppliersologest"]; + + $invoicestatic->type = $val["type"]; $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print ""; print ""; print ""; print ""; - print ""; + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + print ""; + //print ""; print '"; print '"; print ""; @@ -461,34 +484,36 @@ if ($action == 'export_csv') { print ""; print ""; print ""; - print ""; + print "" ; + print ""; print '"; print '"; print ""; } } print ""; - + // Third party foreach ( $tabttc[$key] as $k => $mt ) { print ""; print ""; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print ""; + print ""; + print ""; + //print ""; print '"; print '"; } print ""; - + $var = ! $var; } - + print "
" . $langs->trans("Account") . "" . $langs->trans("Type") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $accountingaccount->label . "" . $companystatic->getNomUrl(0, 'supplier', 16). ' - ' .$invoicestatic->refsupplier .' - '. $accountingaccount->label . "" . $accountingaccount->label . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $langs->trans("VAT") . "" . length_accountg($k) . "" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("VAT") . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accounta($k); - print "" . $langs->trans("ThirdParty"); - print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; - print "" . length_accounta($k)."" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("Code_tiers")."" . $langs->trans("ThirdParty"); + //print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; + //print "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 5166d503b06..961f3f3347c 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -40,10 +40,10 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs -$langs->load("commercial"); $langs->load("compta"); $langs->load("bills"); $langs->load("other"); +$langs->load("main"); $langs->load("accountancy"); $date_startmonth = GETPOST('date_startmonth'); @@ -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,42 +354,45 @@ 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; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $companystatic->ref_client . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + //print '"' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; 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; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - '. utf8_decode ( dol_trunc($accountingaccount->label, 32)) . '"' . $sep; + //print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; } } - + // VAT foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - '. $langs->trans("VAT") . '"' . $sep; + //print '"' . $langs->trans("VAT") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; @@ -398,11 +401,11 @@ if ($action == 'export_csv') { } } } else { - + $form = new Form($db); - + llxHeader('', $langs->trans("SellsJournal")); - + $nom = $langs->trans("SellsJournal"); $nomlink = ''; $periodlink = ''; @@ -415,13 +418,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 ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -451,20 +454,20 @@ if ($action == 'export_csv') { print ""; print ""; print "\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 ""; @@ -474,30 +477,32 @@ if ($action == 'export_csv') { $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; print ""; print ""; print ""; } print ""; - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print ""; print ""; print ""; print ""; - print ""; + //print ""; + print ""; print ""; print ""; print ""; } } - + // VAT foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -505,18 +510,19 @@ if ($action == 'export_csv') { print ""; print ""; print ""; - print ""; + print ""; + //print ""; print ""; print ""; print ""; } } - + $var = ! $var; } - + print "
" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . length_accounta($k); - print "" . $langs->trans("ThirdParty"); - print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; + //print "" . $langs->trans("ThirdParty"); + //print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; + print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref_client . ' - ' . $langs->trans("Code_tiers"). "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $accountingaccount->label . "" . $accountingaccount->label . "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref_client . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)) . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $langs->trans("VAT") . "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref_client .' - '. $langs->trans("VAT") . "" . $langs->trans("VAT") . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 788eaa32e88..ade361fdd51 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -217,7 +217,7 @@ if ($result) { print ''; print ''; print ''; - print '%'; + print '%'; print ''; print ' '; print ''; @@ -233,7 +233,7 @@ if ($result) { while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; - $codeCompta = $objp->account_number . ' ' . $objp->label; + $codeCompta = $objp->account_number . ' - ' . $objp->label; print ""; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 83e83c9bc5d..8a493f73adc 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1931,7 +1931,7 @@ if ($action == 'create' && $user->rights->commande->creer) /* * Commande - */ + */ $nbrow = 9; if (! empty($conf->projet->enabled)) $nbrow ++; @@ -2050,6 +2050,9 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print $object->date ? dol_print_date($object->date, 'daytext') : ' '; + if ($object->hasDelay() && empty($object->date_livraison)) { + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + } } print ''; print ''; @@ -2072,6 +2075,9 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : ' '; + if ($object->hasDelay() && ! empty($object->date_livraison)) { + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + } } print ''; print ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ed1947ec3ca..9eb31ebd608 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -140,10 +140,6 @@ class Commande extends CommonOrder */ var $lines = array(); - // Pour board - var $nbtodo; - var $nbtodolate; - // Multicurrency var $fk_multicurrency; var $multicurrency_code; @@ -3436,6 +3432,22 @@ class Commande extends CommonOrder return max($this->date_commande, $this->date_livraison) < ($now - $conf->commande->client->warning_delay); } + + /** + * Show the customer delayed info + * + * @return string Show delayed information + */ + public function showDelay() + { + global $conf, $langs; + + if (empty($this->date_livraison)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day'); + else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day'); + $text.=' '.($conf->commande->client->warning_delay>0?'+':'-').' '.round(abs($conf->commande->client->warning_delay)/3600/24,1).' '.$langs->trans("days").' < '.$langs->trans("Today"); + + return $text; + } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e5f8a62acb5..91a602c31a6 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -554,7 +554,7 @@ if ($resql) // Warning late icon print ''; if ($generic_commande->hasDelay()) { - print img_picto($langs->trans("Late"), "warning"); + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); } if(!empty($objp->note_private)) { diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 880ff92d3d5..b1bf6cd4270 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2012-2014 Marcos García + * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2011-2015 Alexandre Spangaro * Copyright (C) 2015 Florian Henry * @@ -209,29 +209,13 @@ if ($id > 0 || ! empty($ref)) $result=$object->fetch($id, $ref); - // Chargement des categories bancaires dans $options - $nbcategories=0; + // Load bank groups + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; + $bankcateg = new BankCateg($db); + $options = array(); - $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " ORDER BY label"; - - $result = $db->query($sql); - if ($result) - { - $var=True; - $num = $db->num_rows($result); - $i = 0; - $options = ''; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $options.= ''."\n"; - $nbcategories++; - $i++; - } - $db->free($result); + foreach ($bankcateg->fetchAll() as $bankcategory) { + $options[$bankcategory->id] = $bankcategory->label; } // Definition de sql_rech et param @@ -397,15 +381,11 @@ if ($id > 0 || ! empty($ref)) } } - if ($object->type != 2 && $object->rappro) - { + if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate - if ($user->rights->banque->consolidate) - { - print ''.$langs->trans("Conciliate").''; - } - else - { + if ($user->rights->banque->consolidate) { + print ''.$langs->trans("Conciliate").''; + } else { print ''.$langs->trans("Conciliate").''; } } @@ -494,9 +474,9 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - if ($nbcategories) - { - print '
'.$langs->trans("Rubrique").': '; + if ($options) { + print '
'.$langs->trans("Rubrique").': '; + print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); } print ''; print ''; @@ -529,8 +509,11 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("Credit").''; print ''.$langs->trans("BankBalance").''; print ''; - if ($object->type != 2 && $object->rappro) print $langs->trans("AccountStatementShort"); - else print ' '; + if ($object->canBeConciliated() > 0) { + print $langs->trans("AccountStatementShort"); + } else { + print ' '; + } print ''; print '
'; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index c8d7f036cdc..b33b0438552 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -292,7 +292,7 @@ if ($action == 'create') // Currency print ''.$langs->trans("Currency").''; print ''; - $selectedcode=$account->account_currency_code; + $selectedcode=$account->currency_code; if (! $selectedcode) $selectedcode=$conf->currency; print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); @@ -369,10 +369,10 @@ if ($action == 'create') print ''; print ''.$langs->trans("BalanceMinimalAllowed").''; - print 'account_min_allowed).'">'; + print 'min_allowed).'">'; print ''.$langs->trans("BalanceMinimalDesired").''; - print 'account_min_desired).'">'; + print 'min_desired).'">'; print ''; print '
'; @@ -583,7 +583,7 @@ else // Currency print ''.$langs->trans("Currency").''; print ''; - $selectedcode=$account->account_currency_code; + $selectedcode=$account->currency_code; if (! $selectedcode) $selectedcode=$conf->currency; print $langs->trans("Currency".$selectedcode); print ''; @@ -851,7 +851,7 @@ else print ''; print ''; print ''; - $selectedcode=$account->account_currency_code; + $selectedcode=$account->currency_code; if (! $selectedcode) $selectedcode=$conf->currency; print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 1d9da7f9f59..48e8e738fef 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Charles-Fr BENKE * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García * * 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 @@ -27,6 +28,7 @@ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -36,70 +38,39 @@ $action=GETPOST('action'); if (!$user->rights->banque->configurer) accessforbidden(); - +$bankcateg = new BankCateg($db); +$categid = GETPOST('categid'); +$label = GETPOST("label"); /* * Add category */ if (GETPOST('add')) { - if (GETPOST("label")) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; - $sql.= "label"; - $sql.= ", entity"; - $sql.= ") VALUES ("; - $sql.= "'".$db->escape(GETPOST("label"))."'"; - $sql.= ", ".$conf->entity; - $sql.= ")"; - - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + if ($label) { + $bankcateg = new BankCateg($db); + $bankcateg->label = GETPOST('label'); + $bankcateg->create($user); } } -/* - * Update category - */ -if (GETPOST('update')) -{ - if (GETPOST("label")) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ "; - $sql.= "set label='".$db->escape(GETPOST("label"))."'"; - $sql.= " WHERE rowid = '".GETPOST('categid')."'"; - $sql.= " AND entity = ".$conf->entity; +if ($categid) { + $bankcateg = new BankCateg($db); - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); + if ($bankcateg->fetch($categid) > 0) { + + //Update category + if (GETPOST('update') && $label) { + + $bankcateg->label = $label; + $bankcateg->update($user); + } + //Delete category + if ($action == 'delete') { + $bankcateg->delete($user); } } } -/* -* Action suppression catégorie -*/ -if ($action == 'delete') -{ - if (GETPOST('categid')) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE rowid = '".GETPOST('categid')."'"; - $sql.= " AND entity = ".$conf->entity; - - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } - } -} - - /* * View @@ -174,5 +145,3 @@ if ($action != 'edit') print ''; llxFooter(); - -$db->close(); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 5c5b7cf1479..bad817d7a21 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -166,6 +166,13 @@ class Account extends CommonObject */ public $currency_code; + /** + * Currency code + * @var string + * @deprecated Use currency_code instead + */ + public $account_currency_code; + /** * Authorized minimum balance * @var float @@ -358,7 +365,7 @@ class Account extends CommonObject * @param string $banque Bank of cheque writer * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, $user, $emetteur='',$banque='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='') { // Deprecatîon warning if (is_numeric($oper)) { @@ -409,63 +416,55 @@ class Account extends CommonObject $datev = $date; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank ("; - $sql.= "datec"; - $sql.= ", dateo"; - $sql.= ", datev"; - $sql.= ", label"; - $sql.= ", amount"; - $sql.= ", fk_user_author"; - $sql.= ", num_chq"; - $sql.= ", fk_account"; - $sql.= ", fk_type"; - $sql.= ",emetteur,banque"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", '".$this->db->idate($date)."'"; - $sql.= ", '".$this->db->idate($datev)."'"; - $sql.= ", '".$this->db->escape($label)."'"; - $sql.= ", ".price2num($amount); - $sql.= ", '".$user->id."'"; - $sql.= ", ".($num_chq?"'".$num_chq."'":"null"); - $sql.= ", '".$this->rowid."'"; - $sql.= ", '".$oper."'"; - $sql.= ", ".($emetteur?"'".$this->db->escape($emetteur)."'":"null"); - $sql.= ", ".($banque?"'".$this->db->escape($banque)."'":"null"); - $sql.= ")"; + $accline = new AccountLine($this->db); + $accline->datec = $now; + $accline->dateo = $date; + $accline->datev = $datev; + $accline->label = $label; + $accline->amount = $amount; + $accline->fk_user_author = $user->id; + $accline->fk_account = $this->rowid; + $accline->fk_type = $oper; - dol_syslog(get_class($this)."::addline", LOG_DEBUG); - if ($this->db->query($sql)) - { - $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank"); - if ($categorie) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; - $sql.= "lineid"; - $sql.= ", fk_categ"; - $sql.= ") VALUES ("; - $sql.= "'".$rowid."'"; - $sql.= ", '".$categorie."'"; - $sql.= ")"; + if ($num_chq) { + $accline->num_chq = $num_chq; + } - $result = $this->db->query($sql); - if (! $result) - { - $this->db->rollback(); - $this->error=$this->db->error(); - return -3; - } - } - $this->db->commit(); - return $rowid; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } + if ($emetteur) { + $accline->emetteur = $emetteur; + } + + if ($banque) { + $accline->bank_chq = $banque; + } + + if ($accline->insert() > 0) { + + if ($categorie) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; + $sql .= "lineid"; + $sql .= ", fk_categ"; + $sql .= ") VALUES ("; + $sql .= "'".$accline->id."'"; + $sql .= ", '".$categorie."'"; + $sql .= ")"; + + $result = $this->db->query($sql); + if (!$result) { + $this->db->rollback(); + $this->error = $this->db->error(); + return -3; + } + } + + $this->db->commit(); + return $accline->id; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } /** * Create bank account into database @@ -473,7 +472,7 @@ class Account extends CommonObject * @param User $user Object user making creation * @return int < 0 if KO, > 0 if OK */ - function create($user='') + function create(User $user = null) { global $langs,$conf, $hookmanager; @@ -567,32 +566,18 @@ class Account extends CommonObject $result=$this->update(); if ($result > 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank ("; - $sql.= "datec"; - $sql.= ", label"; - $sql.= ", amount"; - $sql.= ", fk_account"; - $sql.= ", datev"; - $sql.= ", dateo"; - $sql.= ", fk_type"; - $sql.= ", rappro"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", '(".$langs->trans("InitialBankBalance").")'"; - $sql.= ", ".price2num($this->solde); - $sql.= ", '".$this->id."'"; - $sql.= ", '".$this->db->idate($this->date_solde)."'"; - $sql.= ", '".$this->db->idate($this->date_solde)."'"; - $sql.= ", 'SOLD'"; - $sql.= ", 0"; // Not conciliated by default - $sql.= ")"; + $accline = new AccountLine($this->db); + $accline->datec = $this->db->idate($now); + $accline->label = '('.$langs->trans("InitialBankBalance").')'; + $accline->amount = price2num($this->solde); + $accline->fk_account = $this->id; + $accline->datev = $this->db->idate($this->date_solde); + $accline->dateo = $this->db->idate($this->date_solde); + $accline->fk_type = 'SOLD'; - $resql=$this->db->query($sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - return -3; - } + if ($accline->insert() < 0) { + return -3; + } // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('bankdao')); @@ -633,7 +618,7 @@ class Account extends CommonObject * @param User $user Object user making action * @return int <0 si ko, >0 si ok */ - function update($user='') + function update(User $user = null) { global $langs,$conf, $hookmanager; @@ -731,7 +716,7 @@ class Account extends CommonObject * @param User $user Object user making update * @return int <0 if KO, >0 if OK */ - function update_bban($user='') + function update_bban(User $user = null) { global $conf,$langs; @@ -823,7 +808,7 @@ class Account extends CommonObject $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - $this->rowid = $obj->rowid; // deprecated + $this->rowid = $obj->rowid; $this->ref = $obj->ref; $this->label = $obj->label; $this->type = $obj->courant; @@ -889,7 +874,7 @@ class Account extends CommonObject * @param User $user User deleting * @return int <0 if KO, >0 if OK */ - function delete($user='') + function delete(User $user = null) { global $conf; @@ -939,42 +924,32 @@ class Account extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($statut,$mode=0) - { - global $langs; - $langs->load('banks'); + function LibStatut($statut, $mode = 0) + { + global $langs; + $langs->load('banks'); - if ($mode == 0) - { - if ($statut==0) return $langs->trans("StatusAccountOpened"); - if ($statut==1) return $langs->trans("StatusAccountClosed"); - } - if ($mode == 1) - { - if ($statut==0) return $langs->trans("StatusAccountOpened"); - if ($statut==1) return $langs->trans("StatusAccountClosed"); - } - if ($mode == 2) - { - if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4').' '.$langs->trans("StatusAccountOpened"); - if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5').' '.$langs->trans("StatusAccountClosed"); - } - if ($mode == 3) - { - if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4'); - if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5'); - } - if ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4').' '.$langs->trans("StatusAccountOpened"); - if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5').' '.$langs->trans("StatusAccountClosed"); - } - if ($mode == 5) - { - if ($statut==0) return $langs->trans("StatusAccountOpened").' '.img_picto($langs->trans("StatusAccountOpened"),'statut4'); - if ($statut==1) return $langs->trans("StatusAccountClosed").' '.img_picto($langs->trans("StatusAccountClosed"),'statut5'); - } - } + if ($statut == self::STATUS_OPEN) { + $label = $langs->trans("StatusAccountOpened"); + $picto = img_picto($label, 'statut4'); + } else { + $label = $langs->trans("StatusAccountClosed"); + $picto = img_picto($label, 'statut5'); + } + + if ($mode == 2) { + return $picto.' '.$label; + } elseif ($mode == 3) { + return $picto; + } elseif ($mode == 4) { + return $picto.' '.$label; + } elseif ($mode == 5) { + return $label.' '.$picto; + } + + //There is no short mode for this label + return $label; + } /** @@ -1045,7 +1020,7 @@ class Account extends CommonObject * @param int $filteraccountid To get info for a particular account id * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user,$filteraccountid=0) + function load_board(User $user, $filteraccountid = 0) { global $conf, $langs; @@ -1319,13 +1294,14 @@ class AccountLine extends CommonObject var $fk_account; // Id of bank account var $bank_account_label; // Label of bank account + public $emetteur; /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + function __construct(DoliDB $db) { $this->db = $db; } @@ -1387,7 +1363,7 @@ class AccountLine extends CommonObject $this->num_releve = $obj->num_releve; $this->num_chq = $obj->num_chq; - $this->bank_chq = $obj->bank_chq; + $this->bank_chq = $obj->banque; $this->fk_bordereau = $obj->fk_bordereau; $this->fk_account = $obj->fk_account; @@ -1405,6 +1381,52 @@ class AccountLine extends CommonObject } } + /** + * Inserts a transaction to a bank account + * + * @return int <0 if KO, rowid of the line if OK + */ + public function insert() + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank ("; + $sql .= "datec"; + $sql .= ", dateo"; + $sql .= ", datev"; + $sql .= ", label"; + $sql .= ", amount"; + $sql .= ", fk_user_author"; + $sql .= ", num_chq"; + $sql .= ", fk_account"; + $sql .= ", fk_type"; + $sql .= ",emetteur,banque"; + $sql .= ", rappro"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($this->datec)."'"; + $sql .= ", '".$this->db->idate($this->dateo)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", ".price2num($this->amount); + $sql .= ", '".$this->fk_user_author."'"; + $sql .= ", ".($this->num_chq ? "'".$this->num_chq."'" : "null"); + $sql .= ", '".$this->fk_account."'"; + $sql .= ", '".$this->db->escape($this->fk_type)."'"; + $sql .= ", ".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null"); + $sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null"); + $sql .= ", ".(int) $this->rappro; + $sql .= ")"; + + dol_syslog(get_class($this)."::insert", LOG_DEBUG); + $resql = $this->db->query($sql); + + if (!$resql) { + $this->error = $this->db->lasterror(); + return -1; + } + + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'bank'); + + return $this->id; + } /** * Delete transaction bank line record @@ -1412,7 +1434,7 @@ class AccountLine extends CommonObject * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - function delete($user=null) + function delete(User $user = null) { $nbko=0; @@ -1461,7 +1483,7 @@ class AccountLine extends CommonObject * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - function delete_urls($user=null) + function delete_urls(User $user = null) { $nbko=0; @@ -1499,7 +1521,7 @@ class AccountLine extends CommonObject * @param int $notrigger 0=Disable all triggers * @return int <0 if KO, >0 if OK */ - function update($user,$notrigger=0) + function update(User $user, $notrigger = 0) { $this->db->begin(); @@ -1532,7 +1554,7 @@ class AccountLine extends CommonObject * @param int $cat Category id * @return int <0 if KO, >0 if OK */ - function update_conciliation($user,$cat) + function update_conciliation(User $user, $cat) { $this->db->begin(); diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 5004d13caf1..7487e4a9f48 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2009 Regis Houssin + * Copyright (C) 2016 Marcos García * * 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 @@ -17,346 +18,294 @@ */ /** - * \file compta/bank/class/bankcateg.class.php - * \ingroup banque - * \brief This file is CRUD class file (Create/Read/Update/Delete) for bank categories - * \author Laurent Destailleur + * \file compta/bank/class/bankcateg.class.php + * \ingroup bank + * \brief This file is CRUD class file (Create/Read/Update/Delete) for bank categories */ -// Put here all includes required by your class file -//require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - - /** - * Class to manage bank categories + * Class to manage bank categories */ class BankCateg // extends CommonObject { - //public $element='bank_categ'; //!< Id that identify managed objects - //public $table_element='bank_categ'; //!< Name of table without prefix where object is stored + //public $element='bank_categ'; //!< Id that identify managed objects + //public $table_element='bank_categ'; //!< Name of table without prefix where object is stored - var $id; - var $label; + public $id; + public $label; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } - /** - * Create in database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - function create($user, $notrigger=0) - { - global $conf, $langs; - $error=0; + /** + * Create in database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = 0) + { + global $conf; - // Clean parameters - if (isset($this->label)) $this->label=trim($this->label); + $error = 0; - // Check parameters - // Put here code to add control on parameters values + // Clean parameters + if (isset($this->label)) { + $this->label = trim($this->label); + } - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; - $sql.= "label"; - $sql.= ", entity"; - $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").""; - $sql.= ", ".$conf->entity; - $sql.= ")"; + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; + $sql .= "label"; + $sql .= ", entity"; + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").""; + $sql .= ", ".$conf->entity; + $sql .= ")"; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } - if (! $error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_categ"); + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_categ"); + } - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @return int <0 if KO, >0 if OK - */ - function fetch($id) - { - global $langs,$conf; + /** + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + public function fetch($id) + { + global $conf; - $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as t"; - $sql.= " WHERE t.rowid = ".$id; - $sql.= " AND t.entity = ".$conf->entity; + $sql = "SELECT"; + $sql .= " t.rowid,"; + $sql .= " t.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as t"; + $sql .= " WHERE t.rowid = ".$id; + $sql .= " AND t.entity = ".$conf->entity; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->label = $obj->label; - } - $this->db->free($resql); + $this->id = $obj->rowid; + $this->label = $obj->label; + } + $this->db->free($resql); - return 1; - } - else - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user = null, $notrigger = 0) + { + global $conf; + $error = 0; - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function update($user=null, $notrigger=0) - { - global $conf, $langs; - $error=0; + // Clean parameters + if (isset($this->label)) { + $this->label = trim($this->label); + } - // Clean parameters - if (isset($this->label)) $this->label=trim($this->label); + // Check parameters + // Put here code to add control on parameters values - // Check parameters - // Put here code to add control on parameters values + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ SET"; + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").""; + $sql .= " WHERE rowid=".$this->id; + $sql .= " AND entity = ".$conf->entity; - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ SET"; - $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").""; - $sql.= " WHERE rowid=".$this->id; - $sql.= " AND entity = ".$conf->entity; + $this->db->begin(); - $this->db->begin(); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = 0) + { + global $conf; + $error = 0; - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; + $sql .= " WHERE rowid=".$this->id; + $sql .= " AND entity = ".$conf->entity; - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } + $this->db->begin(); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } - /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function delete($user, $notrigger=0) - { - global $conf, $langs; - $error=0; + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE rowid=".$this->id; - $sql.= " AND entity = ".$conf->entity; + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromClone($fromid) + { + global $user; - $this->db->begin(); + $error = 0; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } - - - - /** - * Load an object from its id and create a new one in database - * - * @param int $fromid Id of object to clone - * @return int New id of clone - */ - function createFromClone($fromid) - { - global $user,$langs; - - $error=0; - - $object=new BankCateg($this->db); + $object = new BankCateg($this->db); $object->context['createfromclone'] = 'createfromclone'; $this->db->begin(); - // Load source object - $object->fetch($fromid); - $object->id=0; - $object->statut=0; + // Load source object + $object->fetch($fromid); + $object->id = 0; + $object->statut = 0; - // Clear fields - // ... + // Create clone + $result = $object->create($user); - // Create clone - $result=$object->create($user); + // Other options + if ($result < 0) { + $this->error = $object->error; + $error++; + } - // Other options - if ($result < 0) - { - $this->error=$object->error; - $error++; - } + unset($object->context['createfromclone']); - if (! $error) - { + // End + if (!$error) { + $this->db->commit(); + return $object->id; + } else { + $this->db->rollback(); + return -1; + } + } + /** + * Returns all bank categories + * + * @return BankCateg[] + */ + public function fetchAll() + { + global $conf; + $return = array(); - } + $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ WHERE entity = ".$conf->entity." ORDER BY label"; + $resql = $this->db->query($sql); - unset($object->context['createfromclone']); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $tmp = new BankCateg($this->db); + $tmp->id = $obj->rowid; + $tmp->label = $obj->label; - // End - if (! $error) - { - $this->db->commit(); - return $object->id; - } - else - { - $this->db->rollback(); - return -1; - } - } + $return[] = $tmp; + } + } + return $return; + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - function initAsSpecimen() - { - $this->id=0; - - $this->label=''; - } + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + $this->label = ''; + } } diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index a01d7d0684b..a17614238be 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -6,6 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García * * 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 @@ -205,24 +206,13 @@ $form = new Form($db); llxHeader(); -// The list of categories is initialized -$sql = "SELECT rowid, label"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; -$sql.= " ORDER BY label"; -$result = $db->query($sql); -if ($result) -{ - $var=True; - $num = $db->num_rows($result); - $i = 0; - $options = ""; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $options .= "\n"; - $i++; - } - $db->free($result); +// Load bank groups +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; +$bankcateg = new BankCateg($db); +$options = array(); + +foreach ($bankcateg->fetchAll() as $bankcategory) { + $options[$bankcategory->id] = $bankcategory->label; } $var=false; @@ -620,7 +610,7 @@ print ''; print ''; } print ''; diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 11cd92cdbbc..ec9420b4587 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García * * 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 @@ -111,28 +112,13 @@ if ($action == 'del') } } +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; +$bankcateg = new BankCateg($db); +$options = array(); -// Load bank groups -$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label"; -$resql = $db->query($sql); -$options=""; -if ($resql) -{ - $var=True; - $num = $db->num_rows($resql); - if ($num > 0) $options .= ''; - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $options .= ''."\n"; - $i++; - } - $db->free($resql); - //print $options; +foreach ($bankcateg->fetchAll() as $bankcategory) { + $options[$bankcategory->id] = $bankcategory->label; } -else dol_print_error($db); - /* * View @@ -236,10 +222,11 @@ if ($resql) print ''.$langs->trans("InputReceiptNumber").': '; print ''; // The only default value is value we just entered print '
'; - if ($options) - { - print $langs->trans("EventualyAddCategory").':
'; - } + if ($options) { + print $langs->trans("EventualyAddCategory").': '; + print Form::selectarray('cat', $options, GETPOST('cat'), 1); + print '
'; + } print '
'.$langs->trans("ThenCheckLinesAndConciliate").' "'.$langs->trans("Conciliate").'"
'; print '
'; @@ -440,14 +427,6 @@ if ($resql) print '
"; } else diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 43587cfa6a0..8ef53f26203 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -143,16 +143,12 @@ if (empty($num)) dol_fiche_end(); print '
'; - - if ($object->type != 2 && $object->rappro) - { + + if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate - if ($user->rights->banque->consolidate) - { - print ''.$langs->trans("Conciliate").''; - } - else - { + if ($user->rights->banque->consolidate) { + print ''.$langs->trans("Conciliate").''; + } else { print ''.$langs->trans("Conciliate").''; } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 81eeed8a5b9..e833c0629b3 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1027,7 +1027,7 @@ else print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecord,'title_accountancy.png',0,'','',$limit); - print $langs->trans("ToCreateAPredefinedInvoice").'

'; + print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; $i = 0; print '
'.$langs->trans("Rubriques").''; if ($user->rights->banque->modifier) { - print ' '; + print Form::selectarray('cat1', $options, '', 1).' '; print '
'; print 'rowid])?' checked':'').'>'; -// print ''; -// print '   '; -// print "trans("Conciliate")."\">"; -// if ($options) -// { -// print "
"; -// } print "
'; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c7bc789c6f4..d227d127f69 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -61,6 +61,7 @@ $ref=GETPOST('ref','alpha'); $socid=GETPOST('socid','int'); $action=GETPOST('action','alpha'); $massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $lineid=GETPOST('lineid','int'); $userid=GETPOST('userid','int'); @@ -131,7 +132,8 @@ if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } - +if (! GETPOST('confirmmassaction')) { $massaction=''; } + $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -533,8 +535,8 @@ if (empty($reshook)) $upload_dir = $diroutputpdf; $file = $upload_dir . '/' . GETPOST('file'); $ret=dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); $action=''; } @@ -714,6 +716,7 @@ if ($resql) if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; if ($search_status != '') $param.='&search_status='.$search_status; if ($search_paymentmode > 0) $param.='search_paymentmode='.$search_paymentmode; + if ($show_files) $param.='&show_files=' .$show_files; $param.=(! empty($option)?"&option=".$option:""); $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); @@ -1055,7 +1058,7 @@ if ($resql) print "\n"; $db->free($resql); - if ($massaction == 'builddoc' || $action == 'remove_file') + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { /* * Show list of available documents @@ -1067,10 +1070,16 @@ if ($resql) $genallowed=$user->rights->facture->lire; $delallowed=$user->rights->facture->lire; - print '
'; - // We disable multilang because we concat already existing pdf. - $formfile->show_documents('unpaid','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$langs->trans("PDFMerge"),''); - } + print '
'; + $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); + $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; + + $formfile->show_documents('massfilesarea','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
'.$langs->trans("ShowTempMassFilesArea").''; + } } else { diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php deleted file mode 100644 index 043a45a0861..00000000000 --- a/htdocs/compta/facture/mergepdftool.php +++ /dev/null @@ -1,1031 +0,0 @@ - - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2014 Raphaël Doursenaud - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Note: Page can be call with param mode=sendremind to bring feature to send - * remind by emails. - */ - -/** - * \file htdocs/compta/facture/mergepdftool.php - * \ingroup facture - * \brief Page to list and build doc of selected invoices - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - -$langs->load("mails"); -$langs->load("bills"); - -$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); -$action = GETPOST('action','alpha'); -$option = GETPOST('option'); -$mode=GETPOST('mode'); -$builddoc_generatebutton=GETPOST('builddoc_generatebutton'); -$month = GETPOST("month","int"); -$year = GETPOST("year","int"); -$filter = GETPOST("filtre"); -if (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x')) -{ - $filter=GETPOST('filtre',2); - //if ($filter != 'payed:0') $option=''; -} -if ($option == 'late') $filter = 'paye:0'; -if ($option == 'unpaidall') $filter = 'paye:0'; -if ($mode == 'sendmassremind' && $filter == '') $filter = 'paye:0'; -if ($filter == '') $filter = 'paye:0'; - -$search_user = GETPOST('search_user','int'); -$search_sale = GETPOST('search_sale','int'); - -// Security check -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user,'facture',$id,''); - -$diroutputpdf=$conf->facture->dir_output . '/unpaid/temp'; -if (! $user->rights->societe->client->voir || $socid) $diroutputpdf.='/private/'.$user->id; // If user has no permission to see all, output dir is specific to user - -$resultmasssend=''; -if (GETPOST('buttonsendremind')) -{ - $action='presend'; - $mode='sendmassremind'; -} - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test must be present to be compatible with all browsers -{ - $search_ref=""; - $search_ref_supplier=""; - $search_user = ""; - $search_sale = ""; - $search_label=""; - $search_company=""; - $search_amount_no_tax=""; - $search_amount_all_tax=""; - $year=""; - $month=""; - $filter=""; - $option=""; -} - - - -/* - * Action - */ - -// Send remind email -if ($action == 'presend' && GETPOST('cancel')) -{ - $action=''; - if (GETPOST('models')=='facture_relance') $mode='sendmassremind'; // If we made a cancel from submit email form, this means we must be into mode=sendmassremind -} - -if ($action == 'presend' && GETPOST('sendmail')) -{ - if (GETPOST('models')=='facture_relance') $mode='sendmassremind'; // If we made a cancel from submit email form, this means we must be into mode=sendmassremind - - if (!isset($user->email)) - { - $error++; - setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); - } - - $countToSend = count($_POST['toSend']); - if (empty($countToSend)) - { - $error++; - setEventMessages($langs->trans("InvoiceNotChecked"), null, 'warnings'); - } - - if (! $error) - { - $nbsent = 0; - $nbignored = 0; - - $arrayofinvoices=GETPOST('toSend','array'); - - $thirdparty=new Societe($db); - $invoicetmp=new Facture($db); - $listofinvoicesid=array(); - $listofinvoicesthirdparties=array(); - $listofinvoicesref=array(); - foreach($arrayofinvoices as $invoiceid) - { - $invoicetmp=new Facture($db); // must create new instance because instance is saved into $listofinvoicesref array for future use - $result=$invoicetmp->fetch($invoiceid); - if ($result > 0) - { - $listoinvoicesid[$invoiceid]=$invoiceid; - $thirdpartyid=$invoicetmp->fk_soc?$invoicetmp->fk_soc:$invoicetmp->socid; - $listofinvoicesthirdparties[$thirdpartyid]=$thirdpartyid; - $listofinvoicesref[$thirdpartyid][$invoiceid]=$invoicetmp; - } - } - //var_dump($listofinvoicesref);exit; - - foreach ($listofinvoicesthirdparties as $thirdpartyid) - { - $result = $thirdparty->fetch($thirdpartyid); - if ($result < 0) - { - dol_print_error($db); - exit; - } - - // Define recipient $sendto and $sendtocc - if (trim($_POST['sendto'])) - { - // Recipient is provided into free text - $sendto = trim($_POST['sendto']); - $sendtoid = 0; - } - elseif ($_POST['receiver'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $thirdparty->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $thirdparty->contact_get_property((int) $_POST['receiver'],'email'); - $sendtoid = $_POST['receiver']; - } - } - if (trim($_POST['sendtocc'])) - { - $sendtocc = trim($_POST['sendtocc']); - } - elseif ($_POST['receivercc'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receivercc'] == 'thirdparty') // Id of third party - { - $sendtocc = $thirdparty->email; - } - else // Id du contact - { - $sendtocc = $thirdparty->contact_get_property((int) $_POST['receivercc'],'email'); - } - } - - //var_dump($listofinvoicesref[$thirdpartyid]); - - $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); - $listofqualifiedinvoice=array(); - $listofqualifiedref=array(); - foreach($listofinvoicesref[$thirdpartyid] as $invoiceid => $invoice) - { - //var_dump($invoice); - $object = $invoice; - //$object = new Facture($db); - //$result = $object->fetch(); - //var_dump($thirdpartyid.' - '.$invoiceid.' - '.$object->statut); - - if ($object->statut != Facture::STATUS_VALIDATED) - { - $nbignored++; - continue; // Payment done or started or canceled - } - - // Read document - // TODO Use future field $object->fullpathdoc to know where is stored default file - // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. - $filename=dol_sanitizeFileName($object->ref).'.pdf'; - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); - $file = $filedir . '/' . $filename; - $mime = 'application/pdf'; - - if (dol_is_file($file)) - { - if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) - { - $object->fetch_thirdparty(); - $sendto = $object->thirdparty->email; - } - - if (empty($sendto)) - { - $nbignored++; - continue; - } - - if (dol_strlen($sendto)) - { - // Create form object - $attachedfiles=array( - 'paths'=>array_merge($attachedfiles['paths'],array($file)), - 'names'=>array_merge($attachedfiles['names'],array($filename)), - 'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) - ); - } - - $listofqualifiedinvoice[$invoiceid]=$invoice; - $listofqualifiedref[$invoiceid]=$invoice->ref; - } - else - { - $nbignored++; - $langs->load("other"); - $resultmasssend.='
'.$langs->trans('ErrorCantReadFile',$file).'
'; - dol_syslog('Failed to read file: '.$file, LOG_WARNING); - continue; - } - - //var_dump($listofqualifiedref); - } - - if (count($listofqualifiedinvoice) > 0) - { - $langs->load("commercial"); - $from = $user->getFullName($langs) . ' <' . $user->email .'>'; - $replyto = $from; - $subject = GETPOST('subject'); - $message = GETPOST('message'); - $sendtocc = GETPOST('sentocc'); - $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO); - - $substitutionarray=array( - '__ID__' => join(', ',array_keys($listofqualifiedinvoice)), - '__EMAIL__' => $thirdparty->email, - '__CHECK_READ__' => '', - //'__LASTNAME__' => $obj2->lastname, - //'__FIRSTNAME__' => $obj2->firstname, - '__FACREF__' => join(', ',$listofqualifiedref), // For backward compatibility - '__REF__' => join(', ',$listofqualifiedref), - '__REFCLIENT__' => $thirdparty->name - ); - - $subject=make_substitutions($subject, $substitutionarray); - $message=make_substitutions($message, $substitutionarray); - - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - //var_dump($filepath); - - // Send mail - require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'); - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1); - if ($mailfile->error) - { - $resultmasssend.='
'.$mailfile->error.'
'; - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - $resultmasssend.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " - - $error=0; - - foreach($listofqualifiedinvoice as $invid => $object) - { - $actiontypecode='AC_FAC'; - $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; - if ($message) - { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg = dol_concatdesc($actionmsg, $message); - } - - // Initialisation donnees - $object->sendtoid = 0; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; // Long text - $object->actionmsg2 = $actionmsg2; // Short text - $object->fk_element = $invid; - $object->elementtype = $invoice->element; - - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - - if (! $error) - { - $resultmasssend.=$langs->trans("MailSent").': '.$sendto."
\n"; - } - else - { - dol_print_error($db); - } - $nbsent++; - } - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $resultmasssend.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $resultmasssend.='
'.$mailfile->error.'
'; - } - else - { - $resultmasssend.='
No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
'; - } - } - } - } - } - - if ($nbsent) - { - $action=''; // Do not show form post if there was at least one successfull sent - setEventMessages($nbsent. '/'.$countToSend.' '.$langs->trans("RemindSent"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("NoRemindSent"), null, 'warnings'); // May be object has no generated PDF file - } - } -} - - -if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_search') && !empty($builddoc_generatebutton)) -{ - if (is_array($_POST['toGenerate'])) - { - $arrayofinclusion=array(); - foreach($_POST['toGenerate'] as $tmppdf) $arrayofinclusion[]=preg_quote($tmppdf.'.pdf','/'); - $factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true); - - // liste les fichiers - $files = array(); - foreach($_POST['toGenerate'] as $basename) - { - foreach($factures as $facture) - { - if (strstr($facture["name"],$basename)) - { - $files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"]; - } - } - } - - // Define output language (Here it is not used because we do only merging existing PDF) - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - // Create empty PDF - $pdf=pdf_getInstance(); - if (class_exists('TCPDF')) - { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - - // Add all others - foreach($files as $file) - { - // Charge un document PDF depuis un fichier. - $pagecount = $pdf->setSourceFile($file); - for ($i = 1; $i <= $pagecount; $i++) - { - $tplidx = $pdf->importPage($i); - $s = $pdf->getTemplatesize($tplidx); - $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); - $pdf->useTemplate($tplidx); - } - } - - // Create output dir if not exists - dol_mkdir($diroutputpdf); - - // Save merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities("Invoices"))); - if ($filter=='paye:0') - { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); - } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; - if ($pagecount) - { - $now=dol_now(); - $file=$diroutputpdf.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; - $pdf->Output($file,'F'); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - - $langs->load("exports"); - setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); - } - } - else - { - setEventMessages($langs->trans('InvoiceNotChecked'), null, 'warnings'); - } -} - -// Remove file -if ($action == 'remove_file') -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $diroutputpdf; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $action=''; -} - - - -/* - * View - */ - -$form = new Form($db); -$formfile = new FormFile($db); -$formother = new FormOther($db); - -$title=$langs->trans("MergingPDFTool"); - -llxHeader('',$title); - -?> - -liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortfield) $sortfield="f.date_lim_reglement"; -if (! $sortorder) $sortorder="ASC"; - -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; - -$sql = "SELECT s.nom as name, s.rowid as socid, s.email"; -$sql.= ", f.rowid as facid, f.facnumber, f.ref_client, f.increment, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp"; -$sql.= ", f.datef as df, f.date_lim_reglement as datelimite"; -$sql.= ", f.paye as paye, f.fk_statut, f.type, f.fk_mode_reglement"; -$sql.= ", sum(pf.amount) as am"; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ",".MAIN_DB_PREFIX."facture as f"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; -// We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -if ($search_user > 0) -{ - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; -} -$sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= " AND f.entity = ".$conf->entity; -$sql.= " AND f.type IN (0,1,3,5)"; -if ($filter == 'paye:0') $sql.= " AND f.fk_statut = 1"; -//$sql.= " AND f.paye = 0"; -if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if (! empty($socid)) $sql .= " AND s.rowid = ".$socid; -if ($filter && $filter != -1) // GETPOST('filtre') may be a string -{ - $filtrearr = explode(",", $filter); - foreach ($filtrearr as $fil) - { - $filt = explode(":", $fil); - $sql .= " AND " . $filt[0] . " = " . $filt[1]; - } -} -if ($search_ref) $sql .= " AND f.facnumber LIKE '%".$db->escape($search_ref)."%'"; -if ($search_refcustomer) $sql .= " AND f.ref_client LIKE '%".$db->escape($search_refcustomer)."%'"; -if ($search_societe) $sql .= " AND s.nom LIKE '%".$db->escape($search_societe)."%'"; -if ($search_paymentmode) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; -if ($search_montant_ht) $sql .= " AND f.total = '".$db->escape($search_montant_ht)."'"; -if ($search_montant_ttc) $sql .= " AND f.total_ttc = '".$db->escape($search_montant_ttc)."'"; -if (GETPOST('sf_ref')) $sql .= " AND f.facnumber LIKE '%".$db->escape(GETPOST('sf_ref'))."%'"; -if ($month > 0) -{ - if ($year > 0) - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; - else - $sql.= " AND date_format(f.datef, '%m') = '$month'"; -} -else if ($year > 0) -{ - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; -} -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; -if ($search_user > 0) -{ - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; -} -$sql.= " GROUP BY s.nom, s.rowid, s.email, f.rowid, f.facnumber, f.ref_client, f.increment, f.total, f.tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp,"; -$sql.= " f.datef, f.date_lim_reglement, f.paye, f.fk_statut, f.type, f.fk_mode_reglement"; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; -$sql.= " ORDER BY "; -$listfield=explode(',',$sortfield); -foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.","; -$sql.= " f.facnumber DESC"; -//print $sql; -//$sql .= $db->plimit($limit+1,$offset); - -$resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - - if (! empty($socid)) - { - $soc = new Societe($db); - $soc->fetch($socid); - } - - $param=""; - $param.=(! empty($socid)?"&socid=".$socid:""); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_refcustomer) $param.='&search_ref='.urlencode($search_refcustomer); - if ($search_societe) $param.='&search_societe='.urlencode($search_societe); - if ($search_societe) $param.='&search_paymentmode='.urlencode($search_paymentmode); - if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_ttc) $param.='&search_montant_ttc='.urlencode($search_montant_ttc); - if ($late) $param.='&late='.urlencode($late); - if ($mode) $param.='&mode='.urlencode($mode); - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); - - //$titre=(! empty($socid)?$langs->trans("BillsCustomersUnpaidForCompany",$soc->name):$langs->trans("BillsCustomersUnpaid")); - $titre=(! empty($socid)?$langs->trans("BillsCustomersForCompany",$soc->name):$langs->trans("BillsCustomers")); - if ($option == 'late') $titre.=' ('.$langs->trans("Late").')'; - //else $titre.=' ('.$langs->trans("All").')'; - - $link=''; - //if (empty($option) || $option == 'late') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidAll").''; - //if (empty($option) || $option == 'unpaidall') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidLateOnly").''; - - $param.=(! empty($option)?"&option=".$option:""); - - print load_fiche_titre($titre,$link); - //print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',0); // We don't want pagination on this page - - $arrayofinvoices=GETPOST('toSend','array'); - if ($action == 'presend' && count($arrayofinvoices) == 0 && ! GETPOST('cancel')) - { - setEventMessages($langs->trans("InvoiceNotChecked"), null, 'errors'); - $action='list'; - $mode='sendmassremind'; - } - else - { - $invoicetmp=new Facture($db); - $listofinvoicesid=array(); - $listofinvoicesthirdparties=array(); - $listofinvoicesref=array(); - foreach($arrayofinvoices as $invoiceid) - { - $result=$invoicetmp->fetch($invoiceid); - if ($result > 0) - { - $listofinvoicesid[$invoiceid]=$invoiceid; - $thirdpartyid=$invoicetmp->fk_soc?$invoicetmp->fk_soc:$invoicetmp->socid; - $listofinvoicesthirdparties[$thirdpartyid]=$thirdpartyid; - $listofinvoicesref[$thirdpartyid][$invoiceid]=$invoicetmp->ref; - } - } - } - print '
'; - - if (GETPOST('modelselected')) { - $action = 'presend'; - } - if (! empty($mode) && $action == 'presend') - { - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', $langs->trans("SendRemind")); - - $topicmail="MailTopicSendRemindUnpaidInvoices"; - $modelmail="facture_relance"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='inv'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'inv'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelectedForRemind"); - if (count($listofinvoicesthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofinvoicesthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - //$formmail->substit['__REF__']=''; - $formmail->substit['__SIGNATURE__']=$user->signature; - //$formmail->substit['__REFCLIENT__']=''; - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['facid']=join(',',$arrayofinvoices); - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); - } - - print ''; - print ''; - if ($late) print ''; - - if ($resultmasssend) - { - print '
'.$langs->trans("ResultOfMassSending").':
'."\n"; - print $langs->trans("Selected").': '.$countToSend."\n
"; - print $langs->trans("Ignored").': '.$nbignored."\n
"; - print $langs->trans("Sent").': '.$nbsent."\n
"; - //print $resultmasssend; - print '
'; - } - - $i = 0; - - // If the user can view prospects other than his' - $moreforfilter=''; - if ($user->rights->societe->client->voir || $socid) - { - $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300'); - $moreforfilter.='
'; - } - // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) - { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - $moreforfilter.='
'; - } - if (! empty($moreforfilter)) - { - print '
'; - print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - print '
'; - - print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans('RefCustomer'),$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"f.fk_mode_reglement","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Taxes"),$_SERVER["PHP_SELF"],"f.tva","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); - print "\n"; - - // Lignes des champs de filtre - print ''; - // Ref - print ''; - print ''; - print ''; - // Late - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - if ($num > 0) - { - $var=true; - $total_ht=0; - $total_tva=0; - $total_ttc=0; - $total_paid=0; - - $facturestatic=new Facture($db); - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $date_limit=$db->jdate($objp->datelimite); - - $var=!$var; - - print ""; - $classname = "impayee"; - - print '\n"; - - // Customer ref - print ''; - - print ''."\n"; - print ''."\n"; - - print ''; - - // Payment mode - print ''; - - - print ''; - print ''; - print ''; - print ''; - - // Remain to receive - print ''; - - // Status of invoice - print ''; - - if (empty($mode)) - { - // Checkbox to merge - print '' ; - } - else - { - // Checkbox to send remind - print '' ; - } - - print "\n"; - $total_ht+=$objp->total_ht; - $total_tva+=($objp->total_tva + $tx1 + $tx2 + $revenuestamp); - $total_ttc+=$objp->total_ttc; - $total_paid+=$objp->am + $cn + $dep; - - $i++; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - - print "
'; - print ''; - print ''; - print ''; - print ''; - $syear = $year; - $formother->select_year($syear?$syear:-1,'year',1, 20, 5); - print ''; - print ' '.$langs->trans("Late"); - print ''; - $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1); - print '   '; - $liststatus=array('paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid")); - print $form->selectarray('filtre', $liststatus, $filter, 1); - print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(1, empty($mode)?'checkformerge':'checkforsend'); - print $searchpitco; - print '
'; - - $facturestatic->id=$objp->facid; - $facturestatic->ref=$objp->facnumber; - $facturestatic->type=$objp->type; - $facturestatic->statut=$objp->fk_statut; - $facturestatic->date_lim_reglement= $db->jdate($objp->datelimite); - - print ''; - - // Ref - print ''; - - // Warning picto - print ''; - - // PDF Picto - print ''; - - print '
'; - print $facturestatic->getNomUrl(1); - print ''; - if ($facturestatic->hasDelay()) { - print img_warning($langs->trans("Late")); - } - print ''; - $filename=dol_sanitizeFileName($objp->facnumber); - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->facnumber); - print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); - print '
'; - - print "
'; - print $objp->ref_client; - print ''.dol_print_date($db->jdate($objp->df),'day').''.dol_print_date($db->jdate($objp->datelimite),'day').''; - $thirdparty=new Societe($db); - $thirdparty->id=$objp->socid; - $thirdparty->name=$objp->name; - $thirdparty->client=$objp->client; - $thirdparty->code_client=$objp->code_client; - print $thirdparty->getNomUrl(1,'customer'); - print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $objp->fk_mode_reglement, 'none', '', -1); - print ''.price($objp->total_ht).''.price($objp->total_tva); - $tx1=price2num($objp->localtax1); - $tx2=price2num($objp->localtax2); - $revenuestamp=price2num($objp->revenuestamp); - if (! empty($tx1) || ! empty($tx2) || ! empty($revenuestamp)) print '+'.price($tx1 + $tx2 + $revenuestamp); - print ''.price($objp->total_ttc).''; - $cn=$facturestatic->getSumCreditNotesUsed(); - $dep=$facturestatic->getSumDepositsUsed(); - if (! empty($objp->am)) print price($objp->am); - if (! empty($objp->am) && ! empty($cn)) print '+'; - if (! empty($cn)) print price($cn); - if (! empty($dep)) print price(-$dep); - print ''.(((! empty($objp->total_ttc) || ! empty($objp->am) || ! empty($cn) || ! empty($dep)) && ($objp->total_ttc - $objp->am - $cn - $dep)) ? price($objp->total_ttc - $objp->am - $cn - $dep):' ').''; - print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am); - print ''; - if (! empty($formfile->infofiles['extensions']['pdf'])) - print ''; - print ''; - $selected=0; - if (in_array($objp->facid, $arrayofinvoices)) $selected=1; - if ($objp->email) print ''; - else print img_picto($langs->trans("NoEMail"), 'warning.png'); - print '
'.$langs->trans("Total").''.price($total_ht).''.price($total_tva).''.price($total_ttc).''.price($total_paid).''.price($total_ttc - $total_paid).'  
"; - - - if (empty($mode)) - { - /* - * Show list of available documents - */ - $filedir=$diroutputpdf; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->lire; - - print '
'; - // We disable multilang because we concat already existing pdf. - $formfile->show_documents('unpaid','',$filedir,$urlsource,$genallowed,$delallowed,'',1,1,0,48,1,$param,$langs->trans("PDFMerge"),$langs->trans("PDFMerge")); - } - else - { - if ($action != 'presend') - { - print '
'; - print ''; - print '
'; - print '
'; - } - } - - print ''; - - $db->free($resql); -} -else dol_print_error($db,''); - - -llxFooter(); -$db->close(); diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index aded1c6aa1f..566a2ff53cc 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -77,7 +77,7 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) else { $db->rollback(); - $mesg='
'.$localtax->error.'
'; + setEventMessages($localtax->error, $localtax->errors, 'errors'); $_GET["action"]="create"; } } @@ -112,18 +112,19 @@ if ($_GET["action"] == 'delete') { $localtax->error=$accountline->error; $db->rollback(); - $mesg='
'.$localtax->error.'
'; + setEventMessages($localtax->error, $localtax->errors, 'errors'); } } else { $db->rollback(); - $mesg='
'.$localtax->error.'
'; + setEventMessages($localtax->error, $localtax->errors, 'errors'); } } else { - $mesg='
Error try do delete a line linked to a conciliated bank transaction
'; + $mesg='Error try do delete a line linked to a conciliated bank transaction'; + setEventMessages($mesg, null, 'errors'); } } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 7fd5cb10483..33d02bff05b 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -65,11 +65,13 @@ if ($action == 'create') $result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET); if ($result < 0) { - $mesg='
'.$bprev->error.'
'; + setEventMessages($bprev->error , $bprev->errors, 'errors'); } if ($result == 0) { - $mesg='
'.$langs->trans("NoInvoiceCouldBeWithdrawed").'
'; + $mesg=''; + $mesg=$langs->trans("NoInvoiceCouldBeWithdrawed"); + setEventMessages($mesg, null, 'errors'); foreach($bprev->invoice_in_error as $key => $val) { $mesg.=$val."
\n"; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 49b4e6af288..9d540a37bb6 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -933,7 +933,6 @@ class FormMail extends Form /** * Set substit array from object * - * @param Object $object Object to use * @param string $mode 'form' or 'emailing' * @return void */ diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index dea00188689..2d328ea7097 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -42,8 +42,10 @@ function contract_prepare_head(Contrat $object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; $head[$h][1] = $langs->trans("ContactsAddresses"); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; $head[$h][2] = 'contact'; $h++; } diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index a6f68800dc4..162aca37c8a 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -45,8 +45,10 @@ function fichinter_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('InterventionContact'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; $head[$h][2] = 'contact'; $h++; } diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 85b30064d0b..4b6f0b7e7d1 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -45,8 +45,10 @@ function facturefourn_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -119,8 +121,10 @@ function ordersupplier_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; $head[$h][2] = 'contact'; $h++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ebe5509078d..ed39c6b45ef 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -630,14 +630,14 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' if ($level > $conf->global->SYSLOG_LEVEL) return; // If adding log inside HTML page is required - if (! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_LOGTOHTML)) + if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility { $conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; } - //TODO: Remove this. MAIN_ENABLE_LOG_HTML should be deprecated and use a log handler dedicated to HTML output + //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments - if (! empty($conf->global->MAIN_ENABLE_LOG_HTML) && ! empty($_GET["log"])) + if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"])) { print "\n\n