diff --git a/ChangeLog b/ChangeLog index 0f2ed877a13..2f9bbcc45c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,7 +39,7 @@ Dolibarr better: - Trigger name SUPPLIER_PROPOSAL_CREATE has been renamed into PROPOSAL_SUPPLIER_CREATE. - A new paramater sqlfilters was introduced to allow filter on any fields int the REST API. Few old parameters, no more required, were also removed. Use this new one if you were using one of them. - +- The trigger that activate or close a contract line is run on a contract line, not on contract. ***** ChangeLog for 4.0.2 compared to 4.0.1 ***** diff --git a/build/debian/README.howto b/build/debian/README.howto index 696ea9a2bef..1b64380cc26 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -73,7 +73,8 @@ Ex: https://alioth.debian.org/users/eldy-guest # msgfmt -v -c -o /dev/null XX.po To have status of translation for language XX # To check package integrity -# lintian --pedantic -E -I package.deb To test a package +# lintian --pedantic -E -I package.deb To test a binary package +# lintian --pedantic -E -I package.dsc To test a source package # To manipulate packages # dpkg -l List all packages @@ -181,8 +182,8 @@ To test a package > cp ../build-area/* /srv/chroot/unstable/tmp > sudo schroot -c name_of_chroot > cd /tmp -> lintian --pedantic -E -I dolibarr*.deb -> lintian --pedantic -E -I dolibarr*.dsc +> lintian --no-tag-display-limit --pedantic -E -I dolibarr*.deb +> lintian --no-tag-display-limit --pedantic -E -I dolibarr*.dsc > dpkg -i dolibarr*.deb ou pour avoir des traces: dpkg -D77777 -i dolibarr*.deb > apt-get install -f diff --git a/build/debian/source/lintian-overrides b/build/debian/source/lintian-overrides index 603c27ef4cd..b4c0956e90f 100644 --- a/build/debian/source/lintian-overrides +++ b/build/debian/source/lintian-overrides @@ -1,5 +1,10 @@ # Remove warning, we want to keep both standard and minified sources. -dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jsgantt/* dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jquery/* -# This is a textual data file -source-is-missing htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json \ No newline at end of file +dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jsgantt/* +dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jstz/* +# Those are false positives, the files are their own sources since +# they are not minified +source-is-missing htdocs/includes/jsgantt/jsgantt.js * +source-is-missing htdocs/includes/jquery/plugins/colorpicker/jquery.colorpicker.js * +source-is-missing htdocs/includes/jquery/plugins/select2/select2.js * +source-is-missing htdocs/includes/jquery/plugins/select2/select2_locale_ar.js * diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index fb3b39feca3..c06d8f0730f 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -1145,6 +1145,9 @@ if ($nboftargetok) { "$DESTI/package_rpm_generic/$FILENAMERPM"=>'Dolibarr installer for Fedora-Redhat-Mandriva-Opensuse (DoliRpm)', "$DESTI/package_rpm_generic/$FILENAMERPMSRC"=>'none', # none means it won't be published on SF "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'Dolibarr installer for Debian-Ubuntu (DoliDeb)', + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'none', # none means it won't be published on SF + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.dsc"=>'none', # none means it won't be published on SF + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.gz"=>'none', # none means it won't be published on SF "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'none', # none means it won't be published on SF "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'Dolibarr installer for Windows (DoliWamp)', "$DESTI/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM', @@ -1155,6 +1158,10 @@ if ($nboftargetok) { "$DESTI/package_rpm_generic/$FILENAMERPM"=>'package_rpm_generic', "$DESTI/package_rpm_generic/$FILENAMERPMSRC"=>'package_rpm_generic', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'package_debian-ubuntu', + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'package_debian-ubuntu', + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.dsc"=>'package_debian-ubuntu', + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.gz"=>'package_debian-ubuntu', + "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows', "$DESTI/standard/$FILENAMETGZ.tgz"=>'standard', diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 0eac0c761c7..c064c74b0ac 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -52,9 +52,13 @@ dol_include_once('/mymodule/class/skeleton_class.class.php'); $langs->load("mymodule"); $langs->load("other"); -// Get parameters +$action=GETPOST('action','alpha'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); + $id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); $backtopage = GETPOST('backtopage'); $myparam = GETPOST('myparam','alpha'); @@ -212,7 +216,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."mytable as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (u.rowid = ef.fk_object)"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (t.rowid = ef.fk_object)"; $sql.= " WHERE 1 = 1"; //$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")"; if ($search_field1) $sql.= natural_search("field1",$search_field1); @@ -239,7 +243,7 @@ $sql.=$db->order($sortfield,$sortorder); //$sql.= $db->plimit($conf->liste_limit+1, $offset); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -329,6 +333,7 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +print '
'; print ''."\n"; // Fields title @@ -531,6 +536,7 @@ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // N print $hookmanager->resPrint; print '
'."\n"; +print '
'."\n"; print ''."\n"; diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index cb3255f981d..47dcce5031b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -155,24 +155,24 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON aa.account_par $sql .= " WHERE asy.rowid = " . $pcgver; if (strlen(trim($search_account))) { - $sql .= " AND aa.account_number like '%" . $search_account . "%'"; + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_label))) { - $sql .= " AND aa.label like '%" . $search_label . "%'"; + $sql .= natural_search("aa.label", $search_label); } if (strlen(trim($search_accountparent))) { - $sql .= " AND aa.account_parent like '%" . $search_accountparent . "%'"; + $sql .= natural_search("aa.account_parent", $search_accountparent); } if (strlen(trim($search_pcgtype))) { - $sql .= " AND aa.pcg_type like '%" . $search_pcgtype . "%'"; + $sql .= natural_search("aa.pcg_type", $search_pcgtype); } if (strlen(trim($search_pcgsubtype))) { - $sql .= " AND aa.pcg_subtype like '%" . $search_pcgsubtype . "%'"; + $sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype); } $sql .= $db->order($sortfield, $sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); @@ -198,11 +198,9 @@ if ($resql) { print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy'); - $i = 0; - print '
'; - // Box to select active chart of accoun + // Box to select active chart of account $var = ! $var; print $langs->trans("Selectchartofaccounts") . " : "; print ''; - print ''; - - $moreforfilter=''; - - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('DateStart') . ': '; - $moreforfilter.=$form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); - $moreforfilter.=$langs->trans('DateEnd') . ': '; - $moreforfilter.=$form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1); - $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("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.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("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_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; - $sous_total_debit = 0; - $sous_total_credit = 0; - $displayed_account = ""; - - foreach ( $object->lines as $line ) { - $var = ! $var; - $link = ''; - $total_debit += $line->debit; - $total_credit += $line->credit; - $description = $object->get_compte_desc($line->numero_compte); // Search description of the account - $root_account_description = $object->get_compte_racine($line->numero_compte); - if(empty($description)){ - $link = '' . img_edit_add() .''; - } - print ''; - - - // Permet d'afficher le compte comptable - if ($root_account_description != $displayed_account) { - - // Affiche un Sous-Total par compte comptable - if ($displayed_account != "") { - print ''; - print "\n"; - print ''; - } - - // Affiche le compte comptable en d�but de ligne - print ""; - print ''; - print ''; - - $displayed_account = $root_account_description; - $sous_total_debit = 0; - $sous_total_credit = 0; + $nbtotalofrecords = -1; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } - - // $object->get_compte_racine($line->numero_compte); - - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - // Comptabilise le sous-total - $sous_total_debit += $line->debit; - $sous_total_credit += $line->credit; - - } - - print ''; - print "\n"; - print ''; - - print ''; - print "\n"; - print ''; - - - print "
'; - print $langs->trans('From'); - print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - print '
'; - 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 '
'.$langs->trans("SubTotal") . ':'.price($sous_total_debit).''.price($sous_total_credit).''.price($sous_total_credit-$sous_total_debit).' 
'. $root_account_description .'
' . length_accountg($line->numero_compte) . '' . $description . '' . number_format($line->debit, 2, ',', ' ') . '' . number_format($line->credit, 2, ',', ' ') . '' . number_format($line->credit - $line->debit, 2, ',', ' ') . '' . $link; - print '
'.$langs->trans("SubTotal") . ':'.price($sous_total_debit).''.price($sous_total_credit).''.price($sous_total_credit-$sous_total_debit).' 
'.$langs->trans("AccountBalance") . ':'.price($total_debit).''.price($total_credit).''.price($total_credit-$total_debit).' 
"; - print '
'; - - llxFooter(); + + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + + print '
'; + + $button = ''; + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, 0, 'title_accountancy', 0, $button); + + + $moreforfilter = ''; + + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('DateStart') . ': '; + $moreforfilter .= $form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); + $moreforfilter .= $langs->trans('DateEnd') . ': '; + $moreforfilter .= $form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1); + $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("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.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("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre('', $_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; + $sous_total_debit = 0; + $sous_total_credit = 0; + $displayed_account = ""; + + foreach ($object->lines as $line) { + $var = ! $var; + $link = ''; + $total_debit += $line->debit; + $total_credit += $line->credit; + $description = $object->get_compte_desc($line->numero_compte); // Search description of the account + $root_account_description = $object->get_compte_racine($line->numero_compte); + if (empty($description)) { + $link = '' . img_edit_add() . ''; + } + print ''; + + // Permet d'afficher le compte comptable + if ($root_account_description != $displayed_account) { + + // Affiche un Sous-Total par compte comptable + if ($displayed_account != "") { + print ''; + print "\n"; + print ''; + } + + // Affiche le compte comptable en d�but de ligne + print ""; + print ''; + print ''; + + $displayed_account = $root_account_description; + $sous_total_debit = 0; + $sous_total_credit = 0; + } + + // $object->get_compte_racine($line->numero_compte); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + // Comptabilise le sous-total + $sous_total_debit += $line->debit; + $sous_total_credit += $line->credit; + } + + print ''; + print "\n"; + print ''; + + print ''; + print "\n"; + print ''; + + print "
'; + print $langs->trans('From'); + print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); + print '
'; + 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 '
' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
' . $root_account_description . '
' . length_accountg($line->numero_compte) . '' . $description . '' . number_format($line->debit, 2, ',', ' ') . '' . number_format($line->credit, 2, ',', ' ') . '' . number_format($line->credit - $line->debit, 2, ',', ' ') . '' . $link; + print '
' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
' . $langs->trans("AccountBalance") . ':' . price($total_debit) . '' . price($total_credit) . '' . 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 f925bf4e4eb..f60b1584455 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -288,12 +288,12 @@ if ($action == 'export_csv') { } $title_page = $langs->trans("Bookkeeping"); -if ($search_date_start || $search_date_end) $title_page .= ' ' . dol_print_date($search_date_start, 'day') . ' - ' . dol_print_date($search_date_end, 'day'); + llxHeader('', $title_page); // List -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); if ($nbtotalofrecords < 0) { @@ -307,6 +307,8 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } +$num=count($object->lines); + if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); print $formconfirm; @@ -354,20 +356,21 @@ print ''; print ''; -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); +$button = ''; +if (count($filter)) $button.= $langs->trans("ExportFilteredList"); +else $button.= $langs->trans("ExportList"); +$button.= ''; + +$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; + +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby, '', $limit); print '
' . "\n"; print '
' . $langs->trans("NewAccountingMvt") . '
'; -print '
'; -if (count($filter)) print $langs->trans("ExportFilteredList"); -else print $langs->trans("ExportList"); -print '
'; print '
' . $langs->trans("DelBookKeeping") . '
'; print '
'; -print ' ' . $langs->trans("GroupByAccountAccounting") . '

'; - print ''; print ''; print_liste_field_titre($langs->trans("TransactionNumShort"), $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); @@ -448,7 +451,9 @@ foreach ($object->lines as $line ) { } print ''; -print ''; +if ($num < $limit) print ''; +else print ''; +print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 3a6a428abed..6308c2d3edc 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -1,7 +1,6 @@ - * largely based on the great work of : + * Copyright (C) 2016 Neil Orley largely based on the great work of : * - Copyright (C) 2013-2016 Olivier Geffroy * - Copyright (C) 2013-2016 Florian Henry * - Copyright (C) 2013-2016 Alexandre Spangaro @@ -18,7 +17,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ /** @@ -72,11 +70,8 @@ $pagenext = $page + 1; if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") $sortfield = "t.rowid"; -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 (empty($search_date_start)) $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); +if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); $object = new BookKeeping($db); @@ -126,16 +121,17 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot } } + /* * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { $search_doc_date = ''; $search_accountancy_code = ''; $search_accountancy_code_start = ''; - $search_label_account = ''; + $search_label_account = ''; $search_mvt_label = ''; $search_direction = ''; $search_ledger_code = ''; @@ -160,13 +156,13 @@ if ($action == 'delmouvconfirm') { * View */ -$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); +$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting"); llxHeader('', $title_page); // List -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); if ($nbtotalofrecords < 0) { @@ -211,7 +207,9 @@ if ($action == 'delbookkeepingyear') { print '
'; -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'title_accountancy',0,'','',$limit); +$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; + +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'title_accountancy',0,$viewflat,'',$limit); // Reverse sort order if ( preg_match('/^asc/i', $sortorder) ) @@ -223,8 +221,6 @@ print ''; -print ' ' . $langs->trans("ViewFlatList") . '

'; - print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''; print price($total_debit); print '
'; print ''; print ''; @@ -335,14 +331,15 @@ foreach ( $object->lines as $line ) { } // Affiche un Sous-Total du dernier compte comptable affiché -print ''; +print ''; +print ''; print "\n"; print ''; // Affiche le Total print ''; -print ''; +print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index d8df8eb5007..b607d055a7a 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -158,7 +158,7 @@ if (! empty($search_code_journal)) { * Mode List */ -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0); if ($nbtotalofrecords < 0) { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index d40d8147ef0..268b5fa69c2 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -402,7 +402,7 @@ class AccountancyExport print length_accountg($line->numero_compte) . $this->separator; print substr(length_accountg($line->numero_compte),0,2) . $this->separator; print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; - print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1)."'".$this->separator; + print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print price2num($line->montant).$this->separator; print $line->sens.$this->separator; print $date . $this->separator; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a6f487c1211..85fccbc543b 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -73,7 +73,7 @@ class BookKeeping extends CommonObject public $id; /** */ - public $doc_date = ''; + public $doc_date; public $doc_type; public $doc_ref; public $fk_doc; @@ -184,9 +184,7 @@ class BookKeeping extends CommonObject $sql .= " WHERE doc_type = '" . $this->doc_type . "'"; $sql .= " AND fk_docdet = " . $this->fk_docdet; $sql .= " AND numero_compte = '" . $this->numero_compte . "'"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $resql = $this->db->query($sql); @@ -200,9 +198,7 @@ class BookKeeping extends CommonObject $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); @@ -214,9 +210,7 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sqlnum .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); @@ -503,9 +497,7 @@ class BookKeeping extends CommonObject $sql .= " t.piece_num"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; if (null !== $ref) { $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; } else { @@ -608,10 +600,9 @@ class BookKeeping extends CommonObject } } } - $sql.= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' WHERE 1 = 1'; + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } @@ -721,9 +712,7 @@ class BookKeeping extends CommonObject } } $sql.= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } @@ -817,9 +806,7 @@ class BookKeeping extends CommonObject } } $sql.= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } @@ -1073,9 +1060,7 @@ class BookKeeping extends CommonObject $sql.= " WHERE 1 = 1"; if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $resql = $this->db->query($sql); if (! $resql) { @@ -1107,9 +1092,7 @@ class BookKeeping extends CommonObject $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $resql = $this->db->query($sql); @@ -1180,9 +1163,12 @@ class BookKeeping extends CommonObject * @return void */ public function initAsSpecimen() { - $this->id = 0; + global $user; - $this->doc_date = ''; + $now=dol_now(); + + $this->id = 0; + $this->doc_date = $now; $this->doc_type = ''; $this->doc_ref = ''; $this->fk_doc = ''; @@ -1190,11 +1176,11 @@ class BookKeeping extends CommonObject $this->code_tiers = ''; $this->numero_compte = ''; $this->label_compte = ''; - $this->debit = ''; + $this->debit = 99.9; $this->credit = ''; $this->montant = ''; $this->sens = ''; - $this->fk_user_author = ''; + $this->fk_user_author = $user->id; $this->import_key = ''; $this->code_journal = ''; $this->piece_num = ''; @@ -1212,9 +1198,7 @@ class BookKeeping extends CommonObject $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); @@ -1245,9 +1229,7 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); @@ -1279,9 +1261,7 @@ class BookKeeping extends CommonObject $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); @@ -1333,9 +1313,7 @@ class BookKeeping extends CommonObject $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); @@ -1404,9 +1382,7 @@ class BookKeeping extends CommonObject $sql .= " AND aa.active = 1"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $pcgver; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " ORDER BY account_number ASC"; dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); @@ -1472,9 +1448,7 @@ class BookKeeping extends CommonObject $sql .= " WHERE aa.account_number = '" . $account . "'"; $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")"; dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -1513,9 +1487,7 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND aa.active = 1"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")"; dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index fab9e81031d..2c538e7a627 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -30,6 +30,10 @@ */ class FormVentilation extends Form { + + private $options_cache = array(); + + /** * Return select filter with date of transaction * @@ -41,9 +45,7 @@ class FormVentilation extends Form $options = array(); $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= ' ORDER BY import_key DESC'; dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG); @@ -69,66 +71,79 @@ class FormVentilation extends Form * @param string $htmlname Name of field in html form * @param int $showempty Add an empty field * @param array $event Event options - * @param int $select_in selectid value is a aa.rowid (0 default) or aa.account_number (1) - * @param int $select_out set value returned by select 0=rowid (default), 1=account_number + * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number + * @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number * @param string $morecss More css non HTML object - * @return string String with HTML select + * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. + * @return string String with HTML select */ - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone') { + function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') + { global $conf; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; - $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - - $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; - $sql .= " AND aa.active = 1"; - $sql .= " ORDER BY aa.account_number"; - - dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); - $resql = $this->db->query($sql); - - if (!$resql) { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); - return -1; - } - - $out = ajax_combobox($htmlname, $event); - - // TODO Add $options in cache so next call will not execute the request - $selected = 0; - $options = array(); - while ($obj = $this->db->fetch_object($resql)) + $options = array(); + if ($usecache && ! empty($this->options_cache[$usecache])) { - $label = length_accountg($obj->account_number) . ' - ' . $obj->label; - $label = dol_trunc($label, $trunclength); - - $select_value_in = $obj->rowid; - $select_value_out = $obj->rowid; - - // Try to guess if we have found default value - if ($select_in == 1) { - $select_value_in = $obj->account_number; - } - if ($select_out == 1) { - $select_value_out = $obj->account_number; - } - // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number - // Because same account_number can be share between different accounting_system and do have the same meaning - if ($selectid != '' && $selectid == $select_value_in) { - //var_dump("Found ".$selectid." ".$select_value_in); - $selected = $select_value_out; - } - - $options[$select_value_out] = $label; + $options = $this->options_cache[$usecache]; } + else + { + $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + + $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; + $sql .= " AND aa.active = 1"; + $sql .= " ORDER BY aa.account_number"; + + dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); + $resql = $this->db->query($sql); + + if (!$resql) { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); + return -1; + } + $out = ajax_combobox($htmlname, $event); + + $selected = 0; + while ($obj = $this->db->fetch_object($resql)) + { + $label = length_accountg($obj->account_number) . ' - ' . $obj->label; + $label = dol_trunc($label, $trunclength); + + $select_value_in = $obj->rowid; + $select_value_out = $obj->rowid; + + // Try to guess if we have found default value + if ($select_in == 1) { + $select_value_in = $obj->account_number; + } + if ($select_out == 1) { + $select_value_out = $obj->account_number; + } + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number + // Because same account_number can be share between different accounting_system and do have the same meaning + if ($selectid != '' && $selectid == $select_value_in) { + //var_dump("Found ".$selectid." ".$select_value_in); + $selected = $select_value_out; + } + + $options[$select_value_out] = $label; + } + $this->db->free($resql); + + if ($usecache) + { + $this->options_cache[$usecache] = $options; + } + } + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); - $this->db->free($resql); return $out; } @@ -232,9 +247,7 @@ class FormVentilation extends Form // Auxiliary customer account $sql = "SELECT DISTINCT code_compta, nom "; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; - } + $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; $sql .= " ORDER BY code_compta"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); @@ -254,9 +267,7 @@ class FormVentilation extends Form // Auxiliary supplier account $sql = "SELECT DISTINCT code_compta_fournisseur, nom "; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; - } + $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; $sql .= " ORDER BY code_compta_fournisseur"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); @@ -297,9 +308,7 @@ class FormVentilation extends Form $sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " ORDER BY date_format(doc_date,'%Y')"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -338,9 +347,7 @@ class FormVentilation extends Form $sql = "SELECT DISTINCT code_journal"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; - if (! empty($conf->multicompany->enabled)) { - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - } + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " ORDER BY code_journal"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 08677974a6d..fea8281935f 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -80,7 +80,7 @@ if ($action == 'validatehistory') { $sqlclean .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; $resql = $db->query($sqlclean); - // Now make the binding + // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; @@ -136,11 +136,13 @@ if ($action == 'validatehistory') { // Now clean $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql1 .= " SET fd.fk_code_ventilation = 0"; - $sql1 .= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql1 .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; - $sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')"; - + $sql1.= " SET fd.fk_code_ventilation = 0"; + $sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; + $sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; + $sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; + $sql1.= " AND f.entity IN (" . getEntity("accountancy", 1) . ")"; + $sql1.=")"; + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); @@ -169,12 +171,10 @@ print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevye print $langs->trans("DescVentilCustomer") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; print '
'; -print '
'; -print '' . $langs->trans("ValidateHistory") . ''; -print '' . $langs->trans("CleanHistory", $year_current) . ''; +//print '
'; // TODO Remove this. Should be done into the repair.php script -if ($conf->global->MAIN_FEATURES_LEVEL > 0) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; -print '
'; +if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; +//print '
'; $sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " , " . MAIN_DB_PREFIX . "facture as f"; @@ -191,8 +191,16 @@ if ($result) { $y = $year_current; +$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; + + + + $var = true; +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); + print '
' . $langs->trans("AccountAccounting") . '
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).' 
'.$langs->trans("Total").':'.$langs->trans("Total").':'; print price($total_debit); print '
'; print ''; print ''; @@ -213,7 +221,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy - +$sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); @@ -239,6 +247,69 @@ if ($resql) { } print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '
\n"; + +print '
'; + + +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); + +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " SUM(fd.total_ht) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy +$sql .= " AND aa.account_number IS NOT NULL"; +$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; + +dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + $var = ! $var; + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; + + + + + +print '
'; +print '
'; + + +print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; print ''; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index b18923a1e1d..7882c3b9320 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -38,6 +38,7 @@ $langs->load("bills"); $langs->load("compta"); $langs->load("main"); $langs->load("accountancy"); +$langs->load("productbatch"); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); @@ -122,6 +123,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $account_parent = ''; // Protection to avoid to mass apply it a second time } + /* * View */ @@ -148,7 +150,7 @@ print ' - '; - + if (! empty($conf->use_javascript_ajax)) + { + $ret.=' + + '; + } + return $ret; } @@ -1453,7 +1459,8 @@ class Form $nodatarole=($comboenhancement?' data-role="none"':''); } - $out.= ''; if ($show_empty) $out.= ''."\n"; if ($show_every) $out.= ''."\n"; @@ -2809,7 +2816,9 @@ class Form /** - * Return list of payment modes + * Return list of payment modes. + * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want. + * See instead to force the default value by the caller. * * @param int $selected Id of payment term to preselect by default * @param string $htmlname Nom de la zone select @@ -5704,6 +5713,7 @@ class Form else $file=get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo; $originalfile=get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo; } + $email=$object->email; } else if ($modulepart=='contact') { @@ -5715,6 +5725,7 @@ class Form else $file=get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo; $originalfile=get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo; } + $email=$object->email; } else if ($modulepart=='userphoto') { diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index ac800d480fc..35fcfb4c25b 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -702,7 +702,7 @@ class FormCompany if (is_object($object) && method_exists($object, 'liste_type_contact')) { $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); - print ''; if ($showempty) print ''; foreach($lesTypes as $key=>$value) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index d79eaae65f0..05a4a8d398e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -549,6 +549,7 @@ class FormFile $buttonlabeltoshow=$buttonlabel; if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate'); + if ($conf->browser->layout == 'phone') $urlsource.='#'.$forname.'_form'; // So we switch to form after a generation if (empty($noform)) $out.= ''; $out.= ''; $out.= ''; @@ -802,7 +803,7 @@ class FormFile $out.= ''."\n"; if (! empty($file_list)) { - $out='
' . $langs->trans("TotalVente") . '
'; + print '
'."\n"; + print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); @@ -970,6 +972,7 @@ class FormFile $editline=0; + print ''."\n"; print ''; print ''; print '
'; @@ -1130,7 +1133,7 @@ class FormFile // Show list of documents if (empty($useinecm)) print load_fiche_titre($langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; - print ''; + print '
'."\n"; print ''; $sortref="fullname"; if ($modulepart == 'invoice_supplier') $sortref='level1name'; @@ -1139,7 +1142,7 @@ class FormFile print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$url,"date","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre('','',''); - print ''; + print ''."\n"; // To show ref or specific information according to view to show (defined by $module) if ($modulepart == 'company') @@ -1275,6 +1278,7 @@ class FormFile if (! $found > 0 || ! is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files $var=!$var; + print ''."\n"; print ''; print ''; - print ''; + //print ''; // Input file name box $var=false; @@ -602,8 +597,6 @@ if ($step == 3 && $datatoimport) } print '
'; if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1,'document'); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 47cc7cd9d89..6d88e735770 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -322,8 +322,8 @@ class FormMail extends Form // Zone to select its email template if (count($modelmail_array)>0) { - $out.= '
'."\n"; - $out.= $langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1); + $out.= '
'."\n"; + $out.= $langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1); if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); $out.= '   '; $out.= ''; @@ -336,7 +336,7 @@ class FormMail extends Form 'invoice_supplier_send','thirdparty' ))) { - $out.= '
'."\n"; + $out.= '
'."\n"; $out.= $langs->trans('SelectMailModel').': '; // Do not put disabled on option, it is already on select and it makes chrome crazy. if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); $out.= '   '; diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php index 2cfeaadd368..14e1a466275 100644 --- a/htdocs/core/class/html.formpropal.class.php +++ b/htdocs/core/class/html.formpropal.class.php @@ -101,7 +101,7 @@ class FormPropal } print ''; } diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 57a4c03c63f..ad592359936 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -68,14 +68,14 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if (! empty($conf->browser->phone)) print '
'; else print '
'; - print ''; + print '
'; if ($canedit) { print ''; print ''; print ''; print ''; } @@ -130,7 +130,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print ''; } @@ -141,7 +141,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print ''; } @@ -151,7 +151,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh // Filter on hours print ''; print ''; - print "'; print ''; - print "
'; print $langs->trans("ActionsToDoBy").'   '; - print ''; + print ''; print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or") . ' '.$langs->trans("ToUserOfGroup").'   '; print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit); @@ -102,7 +102,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print '
'; print $langs->trans("Type"); - print '  '; + print '  '; $multiselect=0; if (! empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) // We use an option here because it adds bugs when used on agenda page "peruser" and "list" { @@ -117,7 +117,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print '
'; print $langs->trans("ThirdParty").'   '; - print ''; + print ''; print $form->select_company($socid, 'socid', '', 1); print '
'; print $langs->trans("Project").'   '; - print ''; + print ''; $formproject->select_projects($socid?$socid:-1, $pid, 'projectid', 0); print '
'; print $langs->trans("Status"); - print '  '; + print '  '; $formactions->form_select_status_action('formaction',$status,1,'status',1,2); print '
'.$langs->trans("VisibleTimeRange").'"; + print ""; print '
'; print ''; if (empty($conf->dol_use_jmobile)) print ' - '; @@ -164,7 +164,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh // Filter on days print '
'.$langs->trans("VisibleDaysRange").'"; + print ""; print '
'; print ''; if (empty($conf->dol_use_jmobile)) print ' - '; @@ -186,7 +186,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if (! empty($conf->browser->phone)) print '
'; else print '
'; - print '"; print "'; + print ''; // Date invoice print ''; print ''; // print ''; @@ -1744,7 +1731,7 @@ if ($action == 'create') print ''; print ''; // print ''; @@ -2066,7 +2053,8 @@ else print ''; // Label - print ''; + print ''; + print ''; print ''; print ''; @@ -2572,6 +2560,7 @@ else include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } + print '
'; print '
'; + print ''; // Center @@ -3475,7 +3494,7 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou * @param string $rounding ''=No rounding * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) - * 'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN) + * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) * @param int $alreadysqlnb Put 1 if you know that content is already universal format number * @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails. * @@ -3525,7 +3544,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) $nbofdectoround=''; if ($rounding == 'MU') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT; elseif ($rounding == 'MT') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT; - elseif ($rounding == 'MS') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_SHOWN; + elseif ($rounding == 'MS') $nbofdectoround=empty($conf->global->MAIN_MAX_DECIMALS_STOCK)?5:$conf->global->MAIN_MAX_DECIMALS_STOCK; elseif (is_numeric($rounding)) $nbofdectoround=$rounding; // For admin info page //print "RR".$amount.' - '.$nbofdectoround.'
'; if (dol_strlen($nbofdectoround)) $amount = round($amount,$nbofdectoround); // $nbofdectoround can be 0. @@ -4003,7 +4022,7 @@ function get_product_localtax_for_country($idprod, $local, $thirdparty_seller) global $db,$mysoc; if (! class_exists('Product')) { - require DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; } $ret=0; @@ -4160,7 +4179,7 @@ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, if ($idprodfournprice > 0) { if (! class_exists('ProductFournisseur')) - require DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; $prodprice = new ProductFournisseur($db); $prodprice->fetch_product_fournisseur_price($idprodfournprice); return $prodprice->fourn_tva_npr; @@ -4168,7 +4187,7 @@ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, elseif ($idprod > 0) { if (! class_exists('Product')) - require DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $prod = new Product($db); $prod->fetch($idprod); return $prod->tva_npr; @@ -4395,7 +4414,7 @@ function picto_required() * Clean a string from all HTML tags and entities * * @param string $StringHtml String to clean - * @param integer $removelinefeed 1=Replace also all lines feeds by a space, 0=Only last one are removed + * @param integer $removelinefeed 1=Replace also new lines by a space, 0=Only last one are removed * @param string $pagecodeto Encoding of input/output string * @return string String cleaned * @@ -4404,6 +4423,7 @@ function picto_required() function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') { $pattern = "/<[^<>]+>/"; + $StringHtml = preg_replace('/]*>/', "\n", $StringHtml); $temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto); $temp = preg_replace($pattern,"",$temp); @@ -4425,7 +4445,7 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') * * @param string $text Input text * @return string Output text - * @see dol_nboflines_bis + * @see dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag */ function dolGetFirstLineOfText($text) { @@ -5486,11 +5506,14 @@ function printCommonFooter($zone='private') });'."\n"; print '});'."\n"; - print ''."\n"; - print 'jQuery(".menuhider").click(function() {'; - print " $('.side-nav').toggle();"; - if ($conf->theme == 'md') print " $('.login_block').toggle();"; - print '});'."\n"; + if (empty($conf->dol_use_jmobile)) + { + print ''."\n"; + print 'jQuery(".menuhider").click(function() {'; + print " $('.side-nav').toggle();"; + if ($conf->theme == 'md') print " $('.login_block').toggle();"; + print '});'."\n"; + } print ''."\n"; } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index bb53a0dd1da..84f61145de7 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -20,7 +20,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/hrm/index.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->hrm->employee->read || $user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); -- Home - Dashboard -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'Dashboard', 0, '', '', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'MyDashboard', 0, '', '', '', 2, 0, __ENTITY__); -- Home - Setup insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$user->admin', __HANDLER__, 'left', 100__+MAX_llx_menu__, 'home', 'setup', 1__+MAX_llx_menu__, '/admin/index.php?leftmenu=setup', 'Setup', 0, 'admin', '', '', 2, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 629db07eb77..ec39ba35302 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -508,7 +508,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("users"); // Home - dashboard - $newmenu->add("/index.php?mainmenu=home&leftmenu=home", $langs->trans("Dashboard"), 0, 1, '', $mainmenu, 'home'); + $newmenu->add("/index.php?mainmenu=home&leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home'); // Setup $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup'); diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index dbb8f9b3f01..efb2ec646c8 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1507,7 +1507,7 @@ class DolibarrModules // Can not be abstract, because we need to insta if ($reinitadminperms) { if (! class_exists('User')) { - require DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; + require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; } $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1"; dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG); diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 89b2230d4e7..fed4489c9db 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -381,7 +381,12 @@ class ImportCsv extends ModeleImports } else { - dol_include_once($file); + $resultload = dol_include_once($file); + if (empty($resultload)) + { + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); + break; + } $classinstance=new $class($this->db); // Try the fetch from code or ref call_user_func_array(array($classinstance, $method),array('', $newval)); @@ -454,6 +459,22 @@ class ImportCsv extends ModeleImports } if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" } + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto') + { + $defaultref=''; + // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function + $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; + if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + { + require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + $modTask = new $obj; + $defaultref = $modTask->getNextValue(null,null); + } + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; + $newval=$defaultref; + } + + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') { $newval = price2num($newval); diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index ed0d537d736..1f8e06eb04d 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -315,9 +315,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder $height_note=0; } - $iniY = $tab_top + 7; - $curY = $tab_top + 7; - $nexY = $tab_top + 7; + $iniY = $tab_top + 11; + $curY = $tab_top + 11; + $nexY = $tab_top + 11; // Loop on each lines for ($i = 0 ; $i < $nblines ; $i++) @@ -637,7 +637,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); + $pdf->line($this->marge_gauche, $tab_top+10, $this->page_largeur-$this->marge_droite, $tab_top+10); } $pdf->SetDrawColor(128,128,128); diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index c75e22ed334..16b930e8907 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -33,7 +33,8 @@ class MailingTargets // This can't be abstract as it is used for some method { var $db; var $error; - + var $tooltip=''; + /** * Constructor @@ -52,11 +53,16 @@ class MailingTargets // This can't be abstract as it is used for some method */ function getDesc() { - global $langs; + global $langs, $form; + $langs->load("mails"); $transstring="MailingModuleDesc".$this->name; - if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring); - else return $this->desc; + $s=''; + if ($langs->trans($transstring) != $transstring) $s=$langs->trans($transstring); + else $s=$this->desc; + + if ($this->tooltip && is_object($form)) $s .= ' '.$form->textwithpicto('', $langs->trans($this->tooltip), 1, 1); + return $s; } /** diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 7b6f8361d24..04c4be3ce2e 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -31,12 +31,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; class mailing_xinputfile extends MailingTargets { var $name='EmailsFromFile'; // Identifiant du module mailing - var $desc='EMails issus d\'un fichier'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + var $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e var $require_module=array(); // Module mailing actif si modules require_module actifs var $require_admin=0; // Module mailing actif pour user admin ou non var $picto='generic'; - - var $db; + var $tooltip='UseFormatFileEmailToTarget'; /** diff --git a/htdocs/core/modules/mailings/xinputuser.modules.php b/htdocs/core/modules/mailings/xinputuser.modules.php index 7832d1f6a93..4c5567f574d 100644 --- a/htdocs/core/modules/mailings/xinputuser.modules.php +++ b/htdocs/core/modules/mailings/xinputuser.modules.php @@ -35,9 +35,8 @@ class mailing_xinputuser extends MailingTargets var $require_module=array(); // Module mailing actif si modules require_module actifs var $require_admin=0; // Module mailing actif pour user admin ou non var $picto='generic'; - - var $db; - + var $tooltip='UseFormatInputEmailToTarget'; + /** * Constructor @@ -104,7 +103,7 @@ class mailing_xinputuser extends MailingTargets global $langs; $s=''; - $s.=''; + $s.=''; return $s; } diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index d3c28b246df..a868bfd2f08 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -162,7 +162,7 @@ class modBanque extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid'; $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account'; - $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank',1).')'; + $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account',1).')'; $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; $r++; @@ -189,7 +189,7 @@ class modBanque extends DolibarrModules $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid'; $this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'"; $this->export_sql_end[$r] .=' AND p.fk_paiement = 7'; - $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank',1).')'; + $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank_account',1).')'; $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; } diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 29825cb995d..eec7cd174cd 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -277,7 +277,7 @@ class modExpedition extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('shipment',1).')'; + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition',1).')'; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; } diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 2999bddd1bd..c0203f7e490 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -380,7 +380,7 @@ class modFournisseur extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture_fournisseur',1).')'; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; $r++; @@ -443,7 +443,7 @@ class modFournisseur extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture_fournisseur',1).')'; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; // Order @@ -552,7 +552,7 @@ class modFournisseur extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; - $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')'; + $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('commande_fournisseur',1).')'; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; } diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index ea7e93924ed..30404a02699 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -206,7 +206,7 @@ class modProjet extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + //Exports //-------- @@ -322,6 +322,40 @@ class modProjet extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' WHERE p.entity = '.$conf->entity; + + + // Import list of tasks + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + $r++; + $this->import_code[$r]='tasksofprojects'; + $this->import_label[$r]='ImportDatasetTasks'; + $this->import_icon[$r]='task'; + $this->import_entities_array[$r]=array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'projet_task','extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) + $this->import_fields_array[$r]=array('t.fk_projet'=>'ProjectRef*','t.ref'=>'RefTask*','t.label'=>'LabelTask*','t.dateo'=>"DateStart",'t.datee'=>"DateEnd",'t.planned_workload'=>"PlannedWorkload",'t.progress'=>"Progress",'t.note_private'=>"NotePrivate",'t.note_public'=>"NotePublic",'t.datec'=>"DateCreation"); + // Add extra fields + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity = ".$conf->entity; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + } + } + // End add extra fields + $this->import_fieldshidden_array[$r]=array('t.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_convertvalue_array[$r]=array( + 't.fk_projet'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project'), + 't.ref'=>array('rule'=>'getrefifauto') + ); + //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); + $this->import_regex_array[$r]=array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); + $this->import_examplevalues_array[$r]=array('t.fk_projet'=>'MyProjectRef','t.ref'=>"auto or TK2010-1234",'t.label'=>"My task",'t.progress'=>"0 (not started) to 100 (finished)",'t.datec'=>'1972-10-10','t.note_private'=>"My private note",'t.note_public'=>"My public note"); + } } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 737bb8e3bf5..1943e3f7b20 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -242,12 +242,12 @@ class modSociete extends DolibarrModules $this->rights[$r][4] = 'contact'; $this->rights[$r][5] = 'export'; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; @@ -282,7 +282,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; - + // Export list of contacts and attributes $r++; $this->export_code[$r]=$this->rights_class.'_'.$r; @@ -300,9 +300,12 @@ class modSociete extends DolibarrModules } $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extrasoc'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; @@ -402,7 +405,7 @@ class modSociete extends DolibarrModules 'sr.code_banque'=>"0000", 'sr.code_guichet'=>"1111",'sr.number'=>"3333333333", 'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333" ); - + // Import Company Salesman $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; @@ -411,7 +414,7 @@ class modSociete extends DolibarrModules $this->import_entities_array[$r]=array('sr.fk_user'=>'user'); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_commerciaux'); $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.fk_user'=>"User*"); - + $this->import_convertvalue_array[$r]=array( 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), 'sr.fk_user'=>array('rule'=>'fetchidfromref','classfile'=>'/user/class/user.class.php','class'=>'User','method'=>'fetch','element'=>'User') diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 0e7b416d72e..97203d402d5 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -101,10 +101,10 @@ class mod_task_simple extends ModeleNumRefTask * Return next value * * @param Societe $objsoc Object third party - * @param Task $task Object Task + * @param Task $object Object Task * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc,$task) + function getNextValue($objsoc,$object) { global $db,$conf; @@ -127,7 +127,7 @@ class mod_task_simple extends ModeleNumRefTask return -1; } - $date=empty($task->date_c)?dol_now():$task->date_c; + $date=empty($object->date_c)?dol_now():$object->date_c; //$yymm = strftime("%y%m",time()); $yymm = strftime("%y%m",$date); @@ -144,12 +144,12 @@ class mod_task_simple extends ModeleNumRefTask * Return next reference not yet used as a reference * * @param Societe $objsoc Object third party - * @param Task $task Object task + * @param Task $object Object task * @return string Next not used reference */ - function task_get_num($objsoc=0,$task='') + function task_get_num($objsoc=0,$object='') { - return $this->getNextValue($objsoc,$task); + return $this->getNextValue($objsoc,$object); } } diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 529814079c1..d89acb22b06 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -102,10 +102,10 @@ class mod_task_universal extends ModeleNumRefTask * Return next value * * @param Societe $objsoc Object third party - * @param Project $project Object project + * @param Task $object Object task * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc,$project) + function getNextValue($objsoc,$object) { global $db,$conf; @@ -120,8 +120,8 @@ class mod_task_universal extends ModeleNumRefTask return 0; } - $date=empty($project->date_c)?dol_now():$project->date_c; - $numFinal=get_next_value($db,$mask,'projet_task','ref','',$objsoc->code_client,$date); + $date=empty($object->date_c)?dol_now():$object->date_c; + $numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date); return $numFinal; } @@ -131,12 +131,12 @@ class mod_task_universal extends ModeleNumRefTask * Return next reference not yet used as a reference * * @param Societe $objsoc Object third party - * @param Project $project Object project + * @param Task $object Object task * @return string Next not used reference */ - function project_get_num($objsoc=0,$project='') + function project_get_num($objsoc=0,$object='') { - return $this->getNextValue($objsoc,$project); + return $this->getNextValue($objsoc,$object); } } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 19d09fd7631..9aa1ca994ef 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -374,6 +374,14 @@ class pdf_azur extends ModelePDFPropales if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); } } + if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) + { + $tmpuser=new User($this->db); + $tmpuser->fetch($object->user_author_id); + $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs); + if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email; + if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone; + } if ($notetoshow) { $tab_top = 88 + $height_incoterms; diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 6acc81f009f..d20184c70b4 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2016 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -33,6 +33,7 @@ print '
'; // Load attribute_label $extrafields->fetch_name_optionals_label($elementtype); +print '
'; print "
'; print '
'; print ''; print '
'; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 3d43108e6a3..f67f1a0daf4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -602,7 +602,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable if (empty($disablevirusscan) && file_exists($src_file) && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { if (! class_exists('AntiVir')) { - require DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php'; } $antivir=new AntiVir($db); $result = $antivir->dol_avscan_file($src_file); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 677b619bd02..1e0e4239763 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -102,7 +102,14 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) /** * Get list of entity id to use * - * @param string $element Current element ('actioncomm', ...) + * @param string $element Current element + * 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', + * 'product', 'productprice', 'stock', + * 'propal', 'facture', 'facture_fourn', + * 'categorie', 'bank_account', 'bank_account', 'adherent', 'user', + * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', + * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', + * 'email_template', 'event', * @param int $shared 0=Return id of entity, 1=Return id entity + shared entities * @return mixed Entity id(s) to use */ @@ -110,6 +117,11 @@ function getEntity($element=false, $shared=0) { global $conf, $mc; + // For backward compatibilty + if ($element == 'actioncomm') $element='agenda'; + if ($element == 'fichinter') $element='intervention'; + if ($element == 'categorie') $element='category'; + if (is_object($mc)) { return $mc->getEntity($element, $shared); @@ -619,17 +631,18 @@ function dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0) * Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields. * * @param string $stringtoescape String to escape - * @param int $keepb Do not clean b tags + * @param int $keepb 1=Preserve b tags (otherwise, remove them) + * @param int $keepn 1=Preserve \r\n strings (otherwise, remove them) * @return string Escaped string * * @see dol_string_nohtmltag */ -function dol_escape_htmltag($stringtoescape,$keepb=0) +function dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0) { // escape quotes and backslashes, newlines, etc. $tmp=dol_html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8'); - if ($keepb) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); - else $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n',""=>'',''=>'')); + if (! $keepb) $tmp=strtr($tmp, array(""=>'',''=>'')); + if (! $keepn) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); } @@ -944,8 +957,8 @@ function dol_get_fiche_end($notab=0) * @param int $nodbprefix Do not include DB prefix to forge table name * @param string $morehtmlleft More html code to show before ref * @param string $morehtmlstatus More html code to show under navigation arrows - * @param string $morehtmlright More html code to show before navigation arrows * @param int $onlybanner Put this to 1, if the card will contains only a banner + * @param string $morehtmlright More html code to show before navigation arrows * @return void */ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='') @@ -1042,6 +1055,12 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); $morehtmlstatus.=$tmptxt; } + elseif ($object->element == 'chargesociales') + { + $tmptxt=$object->getLibStatut(6, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); + $morehtmlstatus.=$tmptxt; + } elseif ($object->element == 'facturerec') { $morehtmlstatus.=''; @@ -3144,7 +3163,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', * @param string $options More parameters for links ('' by default, does not include sortfield neither sortorder) * @param string $sortfield Field to sort on ('' by default) * @param string $sortorder Order to sort ('' by default) - * @param string $center Strin gin the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction() + * @param string $center String in the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction() * @param int $num Number of records found by select with limit+1 * @param int $totalnboflines Total number of records/lines for all pages (if known). Use a negative value to not show number. * @param string $picto Icon to use before title (should be a 32x32 transparent png file) @@ -3155,7 +3174,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', * @param int $hideselectlimit Force to hide select limit * @return void */ -function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) +function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=-1, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) { global $conf,$langs; @@ -3185,7 +3204,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so print '
'; if ($picto && $titre) print img_picto('', $picto, 'class="hideonsmartphone valignmiddle" id="pictotitle"', $pictoisfullpath); print '
'.$titre; - if (!empty($titre) && $savtotalnboflines > 0) print ' ('.$totalnboflines.')'; + if (!empty($titre) && $savtotalnboflines >= 0) print ' ('.$totalnboflines.')'; print '
"; print ''; @@ -68,6 +69,6 @@ foreach($extrafields->attribute_type as $key => $value) } print "
"; - +print ''; ?> diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 4b8d82bce40..123fcef662c 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2012 Laurent Destailleur + * Copyright (C) 2010-2016 Laurent Destailleur * * 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,7 +17,7 @@ * * Javascript code to activate drag and drop on lines * You can use this if you want to be abale to drag and drop rows of a table. - * You must add id="tablelines" ont table level tag and have count($object->lines) or count($taskarray) > 0 + * You must add id="tablelines" on table level tag and have count($object->lines) or count($taskarray) > 0 */ ?> diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 845bc30ce13..3a00ca2c060 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -52,6 +52,7 @@ $userstatic=new User($db); ?> +
+
'; print $langs->trans('CronNote').""; - $doleditor = new DolEditor('note', $object->note, '', 160, 'dolibarr_notes', 'In', true, false, 0, 4, 90); + $doleditor = new DolEditor('note', $object->note, '', 160, 'dolibarr_notes', 'In', true, false, 0, ROWS_4, '90%'); $doleditor->Create(); print ""; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 49d916d2d9d..c400f9d167b 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -225,7 +225,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 125f6ea656e..fd68b028254 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -305,9 +305,6 @@ if ($action == 'create') print ''; print ''; - $nbrows=11; - if (! empty($conf->projet->enabled)) $nbrows++; - // Date print ''; print ''; @@ -356,7 +353,7 @@ if ($action == 'create') print ''; print ''; } @@ -428,11 +425,8 @@ if (! empty($id) && $action == 'edit') print ''; print ''; - $nbrows=12; - if (! empty($conf->projet->enabled)) $nbrows++; - // Date - print "".''; @@ -454,10 +448,10 @@ if (! empty($id) && $action == 'edit') print "\n"; $langs->load("companies"); - print "".''; - print "".''; - print "".''; - print "".''; + print ''; + print ''; + print ''; // Zip / Town @@ -468,7 +462,7 @@ if (! empty($id) && $action == 'edit') print ''; // Country - print ''; @@ -593,9 +587,6 @@ if (! empty($id) && $action != 'edit') print '
'.$langs->trans("Date").''; $form->select_date($donation_date?$donation_date:-1,'','','','',"add",1,1); @@ -346,7 +343,7 @@ if ($action == 'create') print '' . $langs->trans('NotePublic') . ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
' . $langs->trans('NotePrivate') . ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'.$langs->trans("Date").''; + print '
'.$langs->trans("Date").''; $form->select_date($object->date,'','','','',"update"); print '
'.$langs->trans("Company").'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Address").''; + print '
'.$langs->trans("Company").'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Address").''; print '
'.$langs->trans('Country').''; + print '
'.$langs->trans('Country').''; print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'; - $nbrows=12; - if (! empty($conf->projet->enabled)) $nbrows++; - // Ref /* print ''; */ // Date - print '"; @@ -668,13 +659,13 @@ if (! empty($id) && $action != 'edit') // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'.$langs->trans("Ref").''; @@ -604,7 +595,7 @@ if (! empty($id) && $action != 'edit') print '
'.$langs->trans("Date").''; + print '
'.$langs->trans("Date").''; print dol_print_date($object->date,"day"); print "
'; - + print ''; print '
'; print '
'; - + /* * Payments */ @@ -737,16 +728,13 @@ if (! empty($id) && $action != 'edit') dol_print_error($db); } - print '
'; print '
'; print ''; - + print '
'; - - + dol_fiche_end(); - $remaintopay = $object->amount - $totalpaid; @@ -821,7 +809,7 @@ if (! empty($id) && $action != 'edit') print $formfile->showdocuments('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf); print '
'; - + print '
'; } diff --git a/htdocs/don/list.php b/htdocs/don/list.php index f5ce8b0350b..9ca8a79bb15 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -113,7 +113,7 @@ if (trim($search_name) != '') if ($search_amount) $sql.= natural_search(array('d.amount'), price2num(trim($search_amount)), 1); $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -157,7 +157,9 @@ if ($resql) print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } - print ""; + print '
'; + print '
'."\n"; + print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","", $param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"d.societe","", $param,"",$sortfield,$sortorder); @@ -237,6 +239,7 @@ if ($resql) $i++; } print "
"; + print ''; print "\n"; $db->free($resql); } diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php index 4e5103399d9..ac3a45d5683 100644 --- a/htdocs/ecm/ajax/ecmdatabase.php +++ b/htdocs/ecm/ajax/ecmdatabase.php @@ -28,7 +28,7 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; -require DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $action = GETPOST('action','alpha'); $element = GETPOST('element', 'alpha'); @@ -48,7 +48,7 @@ if (isset($action) && ! empty($action)) if ($action == 'build' && ! empty($element)) { - require DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php'; + require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php'; $ecmdirstatic = new EcmDirectory($db); $ecmdirtmp = new EcmDirectory($db); diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index ce4bf480668..89caaf91824 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2016 Laurent Destailleur * * 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 @@ -159,14 +159,13 @@ llxHeader(); $form=new Form($db); -$fullpath=$conf->ecm->dir_output.'/'.$ecmdir->label.'/'.$urlfile; +$fullpath=$conf->ecm->dir_output.'/'.$relativepath.$urlfile; $file = new stdClass(); $file->section_id=$ecmdir->id; $file->label=$urlfile; $head = ecm_file_prepare_head($file); -dol_fiche_head($head, 'card', $langs->trans("File"), 0, 'generic'); if ($_GET["action"] == 'edit') { @@ -177,8 +176,10 @@ if ($_GET["action"] == 'edit') print ''; } +dol_fiche_head($head, 'card', $langs->trans("File"), 0, 'generic'); + print ''; -print ''; /*print ''; */ -if ($_GET["action"] == 'edit') -{ - print ''; -} + +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + +print ''; print '
'.$langs->trans("Ref").''; +print '
'.$langs->trans("Ref").''; $s=''; $tmpecmdir=new EcmDirectory($db); // Need to create a new one $tmpecmdir->fetch($ecmdir->id); @@ -203,7 +204,7 @@ while ($tmpecmdir && $result > 0) print img_picto('','object_dir').' '.$langs->trans("ECMRoot").' -> '; print $s; print ' -> '; -if (GETPOST('action') == 'edit') print ''; +if (GETPOST('action') == 'edit') print ''; else print $urlfile; print '
'.$langs->trans("Description").''; @@ -234,20 +235,39 @@ print '
'.$langs->trans("TotalSizeOfAttachedFiles").''; print dol_print_size($totalsize); print '
'; - print ''; - print '     '; - print ''; - print '
'.$langs->trans("DirectDownloadLink").''; +$modulepart='ecm'; +$forcedownload=1; +$rellink='/document.php?modulepart='.$modulepart; +if ($forcedownload) $rellink.='&attachment=1'; +if (! empty($object->entity)) $rellink.='&entity='.$object->entity; +$filepath=$relativepath.$file->label; +$rellink.='&file='.urlencode($filepath); +$fulllink=$urlwithroot.$rellink; +print img_picto('','object_globe.png').' '; +print ''; +print ' '.$langs->trans("Download").''; +print '
'; + +dol_fiche_end(); + if ($_GET["action"] == 'edit') { - print ''; + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print ''; } -print ''; // Confirmation de la suppression d'une ligne categorie diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php index 17e1a1a4308..0099e831776 100644 --- a/htdocs/ecm/docmine.php +++ b/htdocs/ecm/docmine.php @@ -222,7 +222,7 @@ if ($action == 'edit') } print ''; -print ''; -print ''; @@ -1028,7 +1028,7 @@ if ($action == 'create') print ''; print ''; print ''; @@ -1241,16 +1241,6 @@ else if ($id > 0 || ! empty($ref)) print '
'.$langs->trans("Ref").''; +print '
'.$langs->trans("Ref").''; $s=''; $tmpecmdir=new EcmDirectory($db); // Need to create a new one $tmpecmdir->fetch($ecmdir->id); @@ -233,7 +233,7 @@ while ($tmpecmdir && $result > 0) $tmpecmdir->ref=$tmpecmdir->label; if ($i == 0 && $action == 'edit') { - $s=''; + $s=''; } else $s=$tmpecmdir->getNomUrl(1).$s; if ($tmpecmdir->fk_parent) @@ -251,7 +251,7 @@ while ($tmpecmdir && $result > 0) print img_picto('','object_dir').' '.$langs->trans("ECMRoot").' -> '; print $s; print '
'.$langs->trans("Description").''; +print '
'.$langs->trans("Description").''; if ($action == 'edit') { print ''; print '
'.$langs->trans('NotePrivate').''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); //print ''; print '
'; - // Ref - /* - print ''; - - // Third party - print ""; - */ - if (! empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) { // Date Start @@ -1283,37 +1273,6 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; - // Project - /* - if (! empty($conf->projet->enabled)) - { - $langs->load('projects'); - print ''; - print ''; - print ''; - }*/ - // Contrat if ($conf->contrat->enabled) { @@ -1355,9 +1314,6 @@ else if ($id > 0 || ! empty($ref)) print ''; } - // Statut - //print ''; - // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -1527,7 +1483,7 @@ else if ($id > 0 || ! empty($ref)) // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('np_desc',$objp->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,70); + $doleditor=new DolEditor('np_desc',$objp->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,'90%'); $doleditor->Create(); print ''; @@ -1589,7 +1545,7 @@ else if ($id > 0 || ! empty($ref)) // editeur wysiwyg if (empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'alpha'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, 70); + $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'alpha'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%'); $doleditor->Create(); } print ''; diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index fc24d8c8326..54392795f13 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -169,7 +169,7 @@ if (! empty($conf->ficheinter->enabled)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('fichinter', 1).")"; + $sql.= " AND f.entity IN (".getEntity('intervention', 1).")"; $sql.= " AND f.fk_statut = 0"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -280,15 +280,15 @@ else dol_print_error($db); /* * interventions to process */ -/* -if (! empty($conf->fichinter->enabled)) + +if (! empty($conf->ficheinter->enabled)) { $sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid"; $sql.=" FROM ".MAIN_DB_PREFIX."fichinter as f"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('fichinter', 1).")"; + $sql.= " AND f.entity IN (".getEntity('intervention', 1).")"; $sql.= " AND f.fk_statut = 1"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -348,9 +348,6 @@ if (! empty($conf->fichinter->enabled)) } else dol_print_error($db); } -*/ - - print ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e1d73ec6e09..80445f6d55e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1961,6 +1961,7 @@ class CommandeFournisseur extends CommonOrder if ($resql) { $result = 0; + $old_statut = $this->statut; $this->statut = $statut; // Call trigger @@ -1974,6 +1975,7 @@ class CommandeFournisseur extends CommonOrder } else { + $this->statut = $old_statut; $this->db->rollback(); $this->error=$this->db->lasterror(); $result = -1; @@ -2288,10 +2290,10 @@ class CommandeFournisseur extends CommonOrder // Clean vat code $vat_src_code=''; - if (preg_match('/\((.*)\)/', $vatrate, $reg)) + if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. + $vatrate = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 828809d43d3..dec7efa22f1 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -41,7 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; if (! empty($conf->supplier_proposal->enabled)) - require DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; + require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; if (!empty($conf->produit->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (!empty($conf->projet->enabled)) { @@ -1371,7 +1371,7 @@ if ($action=='create') $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); $soc = $objectsrc->client; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); @@ -1407,6 +1407,9 @@ if ($action=='create') $note_public = $object->getDefaultCreateValueFor('note_public'); } + // If not defined, set default value from constant + if (empty($cond_reglement_id) && ! empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID)) $cond_reglement_id=$conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; + print ''; print ''; print ''; @@ -1506,7 +1509,7 @@ if ($action=='create') print ''; print ''; //print ''; @@ -1514,7 +1517,7 @@ if ($action=='create') print ''; print ''; //print ''; @@ -2073,6 +2076,7 @@ elseif (! empty($object->id)) include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } + print '
'; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); - print '
".$langs->trans("Company").''.$object->thirdparty->getNomUrl(1)."
'; - - print ''; - if ($action != 'classify') - { - print ''; - } - print '
'; - print $langs->trans('Project'); - print 'id.'">'; - print img_edit($langs->trans('SetProject'),1); - print '
'; - print '
'; - if ($action == 'classify') - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid', 0, 0, 1); - } - else - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none', 0, 0); - } - print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans('NotePublic').''; - $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'.$langs->trans('NotePrivate').''; - $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'; // Add free products/services form @@ -2101,7 +2105,7 @@ elseif (! empty($object->id)) } } print '
'; - + print ''; print ''; dol_fiche_end(); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index d184845cb76..706ca4e143f 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -64,7 +64,7 @@ $search_state=trim(GETPOST("search_state")); $search_country=GETPOST("search_country",'int'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_user=GETPOST('search_user','int'); -$search_request_author=GETPOST('search_request_author','int'); +$search_request_author=GETPOST('search_request_author','alpha'); $search_ht=GETPOST('search_ht'); $search_ttc=GETPOST('search_ttc'); $search_status=(GETPOST('search_status','alpha')!=''?GETPOST('search_status','alpha'):GETPOST('statut','alpha')); // alpha and not intbecause it can be '6,7' @@ -121,7 +121,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search $fieldstosearchall = array( 'cf.ref'=>'Ref', 'cf.ref_supplier'=>'RefSupplierOrder', - //'pd.description'=>'Description', + 'pd.description'=>'Description', 's.nom'=>"ThirdParty", 'cf.note_public'=>'NotePublic', ); @@ -192,7 +192,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_type=''; $search_country=''; $search_type_thirdparty=''; - $search_request_author=-1; + $search_request_author=''; $search_total_ht=''; $search_total_vat=''; $search_total_ttc=''; @@ -205,7 +205,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $deliveryyear=''; $billed=''; $search_array_options=array(); - + } if (empty($reshook)) @@ -248,7 +248,7 @@ if ($socid > 0) $fourn->fetch($socid); $title .= ' - '.$fourn->name; } -if ($status) +if ($status) { if ($status == '1,2,3') $title.=' - '.$langs->trans("StatusOrderToProcessShort"); if ($status == '6,7') $title.=' - '.$langs->trans("StatusOrderCanceled"); @@ -293,14 +293,14 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql.= ' WHERE cf.fk_soc = s.rowid'; -$sql.= ' AND cf.entity IN ('.getEntity('supplier_order', 1).')'; +$sql.= ' AND cf.entity IN ('.getEntity('commande_fournisseur', 1).')'; if ($socid > 0) $sql.= " AND s.rowid = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_ref) $sql .= natural_search('cf.ref', $search_ref); if ($search_refsupp) $sql.= natural_search("cf.ref_supplier", $search_refsupp); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_request_author > 0) $sql.= " AND u.login LIKE '%".$db->escape($search_request_author)."%'"; +if ($search_request_author) $sql.= " AND u.login LIKE '%".$db->escape($search_request_author)."%'"; if ($billed != '' && $billed >= 0) $sql .= " AND cf.billed = ".$billed; //Required triple check because statut=0 means draft filter @@ -371,7 +371,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -382,7 +382,7 @@ $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); if ($resql) -{ +{ if ($socid > 0) { $soc = new Societe($db); @@ -393,7 +393,7 @@ if ($resql) { $title = $langs->trans('ListOfSupplierOrders'); } - + $num = $db->num_rows($resql); $param=''; @@ -410,13 +410,13 @@ if ($resql) if ($search_ref) $param.='&search_ref='.$search_ref; if ($search_company) $param.='&search_company='.$search_company; if ($search_user > 0) $param.='&search_user='.$search_user; - if ($search_request_author > 0) $param.='&search_request_author='.$search_request_author; + if ($search_request_author) $param.='&search_request_author='.$search_request_author; if ($search_sale > 0) $param.='&search_sale='.$search_sale; if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht; if ($search_total_ttc != '') $param.="&search_total_ttc=".$search_total_ttc; if ($search_refsupp) $param.="&search_refsupp=".$search_refsupp; if ($search_status >= 0) $param.="&search_status=".$search_status; - if ($billed != '') $param.="&billed=".$billed; + if ($billed != '') $param.="&billed=".$billed; if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields foreach ($search_array_options as $key => $val) @@ -425,9 +425,9 @@ if ($resql) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - + // Lignes des champs de filtre print '
'; if ($optioncss != '') print ''; @@ -437,9 +437,9 @@ if ($resql) print ''; print ''; print ''; - + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -447,7 +447,7 @@ if ($resql) } $moreforfilter=''; - + // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { @@ -485,11 +485,12 @@ if ($resql) print $moreforfilter; print ''; } - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print ''."\n"; + print '
'; + print '
'."\n"; print ''; if (! empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'],$_SERVER["PHP_SELF"],"cf.ref","",$param,'',$sortfield,$sortorder); @@ -511,9 +512,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -538,7 +539,7 @@ if ($resql) print ''; } // Ref customer - if (! empty($arrayfields['cf.ref_supplier']['checked'])) + if (! empty($arrayfields['cf.ref_supplier']['checked'])) { print ''; } @@ -551,11 +552,11 @@ if ($resql) if (! empty($arrayfields['u.login']['checked'])) { print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (! empty($arrayfields['s.nom']['checked'])) { print ''; } @@ -594,7 +595,7 @@ if ($resql) print ''; } // Date delivery - if (! empty($arrayfields['cf.date_delivery']['checked'])) + if (! empty($arrayfields['cf.date_delivery']['checked'])) { print ''; - } + } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -649,7 +650,7 @@ if ($resql) // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['cf.datec']['checked'])) { @@ -681,13 +682,13 @@ if ($resql) $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; print ''; - + print "\n"; $total=0; $subtotal=0; $productstat_cache=array(); - + $userstatic = new User($db); $objectstatic=new CommandeFournisseur($db); $projectstatic=new Project($db); @@ -699,7 +700,7 @@ if ($resql) { $obj = $db->fetch_object($resql); $var=!$var; - + $objectstatic->id=$obj->rowid; $objectstatic->ref=$obj->ref; $objectstatic->ref_supplier = $obj->ref_supplier; @@ -708,7 +709,7 @@ if ($resql) $objectstatic->total_ttc = $obj->total_ttc; $objectstatic->date_delivery = $db->jdate($obj->date_delivery); $objectstatic->statut = $obj->fk_statut; - + print ""; // Ref @@ -814,7 +815,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Order date if (! empty($arrayfields['cf.date_commande']['checked'])) { @@ -859,7 +860,7 @@ if ($resql) if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; $totalarray['totalttc'] += $obj->total_ttc; } - + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -910,7 +911,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Action column print ''; if (! $i) $totalarray['nbfield']++; @@ -919,6 +920,7 @@ if ($resql) $i++; } print "
'; - //print ''; + print ''; print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; @@ -622,7 +623,7 @@ if ($resql) print ''; print ''; print '
'.yn($obj->billed).'
\n"; + print ''; print "
\n"; if (! empty($conf->facture->enable)) print '
'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'
'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ecad08da51a..f404f5c3029 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley * Copyright (C) 2005-2013 Regis Houssin @@ -529,19 +529,6 @@ if (empty($reshook)) $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); } } - - // Add predefined lines - /* - TODO delete - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { - $product = new Product($db); - $product->fetch($_POST['idprod' . $i]); - $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); - $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); - $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); - } - }*/ } } @@ -1489,7 +1476,7 @@ if ($action == 'create') $optionsav .= ''; } - print '
'.$langs->trans('Type').''; + print '
'.$langs->trans('Type').''; print '
' . "\n"; @@ -1672,7 +1659,7 @@ if ($action == 'create') } // Label - print '
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('DateInvoice').''; @@ -1734,7 +1721,7 @@ if ($action == 'create') print '
'.$langs->trans('NotePublic').''; $note_public = $object->getDefaultCreateValueFor('note_public'); - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'.$langs->trans('NotePrivate').''; $note_private = $object->getDefaultCreateValueFor('note_private'); - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'.$form->editfieldkey("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).'
'.$form->editfieldkey("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).''.$form->editfieldval("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).'
'; global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; @@ -2599,8 +2588,7 @@ else } print '
'; - - + print ''; print ''; dol_fiche_end(); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index ebe65f62122..7ae18da125f 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -127,7 +127,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search $fieldstosearchall = array( 'f.ref'=>'Ref', 'f.ref_supplier'=>'RefSupplier', - //'fd.description'=>'Description', + 'pd.description'=>'Description', 's.nom'=>"ThirdParty", 'f.note_public'=>'NotePublic', ); @@ -246,7 +246,7 @@ $formcompany=new FormCompany($db); llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); $sql = "SELECT"; -if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite,"; $sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label,"; $sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; @@ -266,7 +266,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; $sql.= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn_extrafields as ef on (f.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; +if ($search_all || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; // We'll need this table joined to the select in order to filter by sale @@ -372,7 +372,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -435,7 +435,7 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans("BillsSuppliers").($socid?" - $soc->name":""),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy',0,'','',$limit); + print_barre_liste($langs->trans("BillsSuppliers").($socid?" - $soc->name":""), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); if ($search_all) { @@ -486,7 +486,8 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print ''."\n"; + print '
'; + print '
'."\n"; print ''; if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'],$_SERVER['PHP_SELF'],'f.ref,f.rowid','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['f.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['f.ref_supplier']['label'],$_SERVER["PHP_SELF"],'f.ref_supplier','',$param,'',$sortfield,$sortorder); @@ -984,7 +985,7 @@ if ($resql) print $hookmanager->resPrint; print "
\n"; - + print ''; print "\n"; } else diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 764a875019d..800df6bd812 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -83,13 +83,19 @@ if ($user->societe_id > 0) $hookmanager->initHooks(array('paymentsupplier')); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('paymentsupplier'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +$arrayfields=array(); + /* * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_ref=""; $search_account=""; @@ -100,6 +106,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $day=''; $year=''; $month=''; + $search_array_options=array(); } $parameters=array('socid'=>$socid); @@ -414,8 +421,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ' });'."\n"; print ' '."\n"; } - print ''; - print ''; + + print '
'; + print '
'."\n"; + + print ''; print ''; print ''; print ''; @@ -539,6 +549,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "\n"; } print "
'.$langs->trans('Invoice').''.$langs->trans('RefSupplier').''.$langs->trans('Date').'
\n"; + + print ""; } $db->free($resql); } @@ -585,10 +597,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie */ if (empty($action)) { - if ($page == -1) $page = 0 ; $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $sortfield = GETPOST("sortfield",'alpha'); + $sortorder = GETPOST("sortorder",'alpha'); + $page=GETPOST("page",'int'); + if ($page == -1) { $page = 0 ; } $offset = $limit * $page ; - + $pageprev = $page - 1; + $pagenext = $page + 1; if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='p.datep'; @@ -622,6 +638,14 @@ if (empty($action)) $sql.= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label"; if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= $db->order($sortfield,$sortorder); + + $nbtotalofrecords = -1; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); @@ -631,50 +655,86 @@ if (empty($action)) $i = 0; $var=True; - $paramlist=''; - $paramlist.=($search_ref?"&search_ref=".urlencode($search_ref):""); - $paramlist.=($search_company?"&search_company=".urlencode($search_company):""); - $paramlist.=($search_amount?"&search_amount=".urlencode($search_amount):""); - $paramlist.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); - if ($optioncss != '') $paramlist.='&optioncss='.urlencode($optioncss); - - print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num, 0, 'title_accountancy.png'); + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_ref) $param.=($search_ref?"&search_ref=".urlencode($search_ref):""); + if ($search_company) $param.=($search_company?"&search_company=".urlencode($search_company):""); + if ($search_amount != '') $param.=($search_amount?"&search_amount=".urlencode($search_amount):""); + if ($search_payment_num) $param.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); + if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Add $param from extra fields + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } + + $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); + + print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); print '
'; if ($optioncss != '') print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $moreforfilter=''; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if ($moreforfilter) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; + print '
'."\n"; + print ''; - print_liste_field_titre($langs->trans('RefPayment'),$_SERVER["PHP_SELF"],'p.rowid','',$paramlist,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'dp','',$paramlist,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('ThirdParty'),$_SERVER["PHP_SELF"],'s.nom','',$paramlist,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Type'),$_SERVER["PHP_SELF"],'c.libelle','',$paramlist,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"p.num_paiement","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Account'),$_SERVER["PHP_SELF"],'ba.label','',$paramlist,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Amount'),$_SERVER["PHP_SELF"],'p.amount','',$paramlist,'align="right"',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans('Invoice'),$_SERVER["PHP_SELF"],'ref_supplier','',$paramlist,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('RefPayment'),$_SERVER["PHP_SELF"],'p.rowid','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'dp','',$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('Type'),$_SERVER["PHP_SELF"],'c.libelle','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"p.num_paiement","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Account'),$_SERVER["PHP_SELF"],'ba.label','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Amount'),$_SERVER["PHP_SELF"],'p.amount','',$param,'align="right"',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans('Invoice'),$_SERVER["PHP_SELF"],'ref_supplier','',$param,'',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; // Lines for filters fields print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'; - print ''; + print ''; print ' '; - print ''; + print ''; print ''; $form->select_types_paiements($search_paymenttype,'search_paymenttype','',2,1,1); print ''; - print ''; + print ''; print ''; $form->select_comptes($search_account,'search_account',0,'',1); print ''; - print ''; + print ''; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); @@ -726,6 +786,7 @@ if (empty($action)) $i++; } print "
"; + print ""; print "
\n"; } else diff --git a/htdocs/fourn/paiement/info.php b/htdocs/fourn/paiement/info.php index 409b567959a..24263106052 100644 --- a/htdocs/fourn/paiement/info.php +++ b/htdocs/fourn/paiement/info.php @@ -26,7 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -require DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; $langs->load("bills"); $langs->load("suppliers"); diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 95ff1620691..97184909290 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -120,7 +120,7 @@ if ($fourn_id > 0) $sql .= " AND ppf.fk_soc = ".$fourn_id; } // Count total nb of records without orderby and limit -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/holiday/common.inc.php b/htdocs/holiday/common.inc.php index a047bee9889..574c4394c81 100644 --- a/htdocs/holiday/common.inc.php +++ b/htdocs/holiday/common.inc.php @@ -25,7 +25,7 @@ require_once realpath(dirname(__FILE__)).'/../main.inc.php'; if (! class_exists('Holiday')) { - require DOL_DOCUMENT_ROOT. '/holiday/class/holiday.class.php'; + require_once DOL_DOCUMENT_ROOT. '/holiday/class/holiday.class.php'; } $langs->load("user"); diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 92a93a0d357..51f3a70a409 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -170,7 +170,11 @@ else print '
'."\n"; print ''; - print ''; + $moreforfilter=''; + + print '
'; + print '
'."\n"; + print ""; print ''; if (count($typeleaves)) @@ -244,7 +248,7 @@ else } print '
'.$langs->trans('Employee').'
'; - + print ''; print '
'; } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index c105e588c15..60da780370d 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2013-2016 Laurent Destailleur * Copyright (C) 2012-2016 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -289,8 +289,10 @@ if ($sall) print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } -print ''; -print ""; +print '
'; +print '
'."\n"; + +print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cp.rowid","",'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateCreateCP"),$_SERVER["PHP_SELF"],"cp.date_create","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Employee"),$_SERVER["PHP_SELF"],"cp.fk_user","",'','',$sortfield,$sortorder); @@ -453,6 +455,7 @@ if($holiday_payes == '2') } print '
'; +print ''; print ''; /*if ($user_id == $user->id) diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 8ee69dc54ad..a04ef05c69b 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -71,7 +71,11 @@ if ($lastUpdate) else print $langs->trans('None'); print "
\n"; -print ''; +$moreforfilter=''; + +print '
'; +print '
'."\n"; + print ''; print ''; @@ -122,7 +126,7 @@ if ($log_holiday == '2') print ''."\n"; print '
'."\n"; - +print ''; llxFooter(); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 89d69974577..c4c14ff8d5f 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012 Christophe Battarel * @@ -342,8 +342,6 @@ if ($step == 1 || ! $datatoimport) dol_fiche_head($head, 'step1', $langs->trans("NewImport")); - print ''; - print $langs->trans("SelectImportDataSet").'
'; // Affiche les modules d'imports @@ -387,10 +385,7 @@ if ($step == 1 || ! $datatoimport) } print '
'; - print '
'; - dol_fiche_end(); - } @@ -413,7 +408,7 @@ if ($step == 2 && $datatoimport) print ''; // Module - print ''; + print ''; print ''; // Lot de donnees a importer - print ''; + print ''; print ''; print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule=$objimport->array_import_module[0]->getName(); // Special cas for import common to module/services @@ -422,15 +417,16 @@ if ($step == 2 && $datatoimport) print '
'.$langs->trans("DatasetToImport").'
'.$langs->trans("DatasetToImport").''; print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_icon[0]).' '; print $objimport->array_import_label[0]; print '
'; - print '
'."\n"; + dol_fiche_end(); + print '
'; print ''; @@ -463,9 +459,6 @@ if ($step == 2 && $datatoimport) } print '
'; - - dol_fiche_end(); - } @@ -498,7 +491,7 @@ if ($step == 3 && $datatoimport) print ''; // Module - print ''; + print ''; print ''; // Lot de donnees a importer - print ''; + print ''; print ''; // Source file format - print ''; + print ''; print ''; print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule=$objimport->array_import_module[0]->getName(); // Special cas for import common to module/services @@ -507,7 +500,7 @@ if ($step == 3 && $datatoimport) print '
'.$langs->trans("DatasetToImport").'
'.$langs->trans("DatasetToImport").''; print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_icon[0]).' '; print $objimport->array_import_label[0]; @@ -519,7 +512,7 @@ if ($step == 3 && $datatoimport) //print '
'.$langs->trans("InformationOnSourceFile").'
'.$langs->trans("SourceFileFormat").'
'.$langs->trans("SourceFileFormat").''; $text=$objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format),$text); @@ -528,9 +521,11 @@ if ($step == 3 && $datatoimport) print '
'; - print '
'."\n"; - + + dol_fiche_end(); + print '
'; + print '
'; print ''; print ''; @@ -542,7 +537,7 @@ if ($step == 3 && $datatoimport) print '
'.$langs->trans("ChooseFileToImport",img_picto('','filenew')).'
'.$langs->trans("FileWithDataToImport").'
'.$langs->trans("FileWithDataToImport").'
'; - - dol_fiche_end(); } @@ -719,7 +712,7 @@ if ($step == 4 && $datatoimport) print ''; // Module - print ''; + print ''; print ''; // Lot de donnees a importer - print ''; + print ''; print ''; // Source file format - print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule=$objimport->array_import_module[0]->getName(); // Special cas for import common to module/services @@ -728,7 +721,7 @@ if ($step == 4 && $datatoimport) print '
'.$langs->trans("DatasetToImport").'
'.$langs->trans("DatasetToImport").''; print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_icon[0]).' '; print $objimport->array_import_label[0]; @@ -740,7 +733,7 @@ if ($step == 4 && $datatoimport) //print '
'.$langs->trans("InformationOnSourceFile").'
'.$langs->trans("SourceFileFormat").'
'.$langs->trans("SourceFileFormat").''; $text=$objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format),$text); @@ -748,7 +741,7 @@ if ($step == 4 && $datatoimport) // Separator and enclosure if ($model == 'csv') { - print '
'.$langs->trans("CsvOptions").'
'.$langs->trans("CsvOptions").''; print '
'; print ''; @@ -767,7 +760,7 @@ if ($step == 4 && $datatoimport) } // File to import - print '
'.$langs->trans("FileToImport").'
'.$langs->trans("FileToImport").''; $modulepart='import'; $relativepath=GETPOST('filetoimport'); @@ -777,6 +770,9 @@ if ($step == 4 && $datatoimport) print '
'; + + dol_fiche_end(); + print '
'."\n"; @@ -801,7 +797,7 @@ if ($step == 4 && $datatoimport) print ''; // Title of array with fields - print ''; + print '
'; print ''; print ''; print ''; @@ -999,8 +995,6 @@ if ($step == 4 && $datatoimport) print '
'.$langs->trans("FieldsInSourceFile").''.$langs->trans("FieldsInTargetDatabase").'
'; - dol_fiche_end(); - if ($conf->use_javascript_ajax) { @@ -1183,7 +1177,7 @@ if ($step == 5 && $datatoimport) print ''; // Module - print ''; + print ''; print ''; // Source file format - print ''; + print ''; print ''; + print ''; print ''; print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 98645575a13..8abcac5a6f1 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -179,14 +179,14 @@ print ''; $var=!$var; print ''; $var=!$var; print ''; diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index f794989c59e..e63fb3e85c7 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -203,14 +203,14 @@ print ''; $var=!$var; print ''; $var=!$var; print ''; diff --git a/htdocs/product/admin/dynamic_prices.php b/htdocs/product/admin/dynamic_prices.php index 7c9a46d8972..7949b47c346 100644 --- a/htdocs/product/admin/dynamic_prices.php +++ b/htdocs/product/admin/dynamic_prices.php @@ -322,7 +322,7 @@ if ($action == 'create_updater' || $action == 'edit_updater') { $help = $langs->trans("GlobalVariableUpdaterHelp".$type).'
'.$langs->trans("GlobalVariableUpdaterHelpFormat".$type).''; print ''; print ''; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index e8d75c4ba19..bffc5f15531 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -64,7 +64,7 @@ dol_syslog(join(',', $_GET)); if (! empty($action) && $action == 'fetch' && ! empty($id)) { - require DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $outjson = array(); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f1f226b835f..122e80b2e69 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1,7 +1,7 @@ +/* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Auguria SARL @@ -11,9 +11,10 @@ * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2014 Cédric Gross * Copyright (C) 2014-2015 Ferran Marcet - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2016 Meziane Sof * * 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 @@ -144,7 +145,6 @@ if (empty($reshook)) */ else if ($action == 'builddoc' && $user->rights->produit->creer) { - // Save last template used to generate document if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); @@ -749,7 +749,7 @@ if (empty($reshook)) { $buyprice = $result; } - + $result = $facture->addline( $desc, $pu_ht, @@ -790,7 +790,6 @@ if (empty($reshook)) else { $action=""; setEventMessages($langs->trans("WarningSelectOneDocument"), null, 'warnings'); - } } } @@ -822,6 +821,23 @@ $formfile = new FormFile($db); $formproduct = new FormProduct($db); if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +// Load object modBarCodeProduct +$res=0; +if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) +{ + $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); + $dirbarcode=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); + foreach ($dirbarcode as $dirroot) + { + $res=dol_include_once($dirroot.$module.'.php'); + if ($res) break; + } + if ($res > 0) + { + $modBarCodeProduct =new $module(); + } +} + if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { @@ -859,22 +875,6 @@ else $modCodeProduct = new $module(); } - // Load object modBarCodeProduct - if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) - { - $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); - $dirbarcode=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); - foreach ($dirbarcode as $dirroot) - { - $res=dol_include_once($dirroot.$module.'.php'); - if ($res) break; - } - if ($res > 0) - { - $modBarCodeProduct =new $module(); - } - } - print '
'; print ''; print ''; @@ -891,11 +891,12 @@ else dol_fiche_head(''); - print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule=$objimport->array_import_module[0]->getName(); // Special cas for import common to module/services @@ -1204,7 +1198,7 @@ if ($step == 5 && $datatoimport) //print '
'.$langs->trans("InformationOnSourceFile").'
'.$langs->trans("SourceFileFormat").'
'.$langs->trans("SourceFileFormat").''; $text=$objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format),$text); @@ -1212,7 +1206,7 @@ if ($step == 5 && $datatoimport) // Separator and enclosure if ($model == 'csv') { - print '
'.$langs->trans("CsvOptions").'
'.$langs->trans("CsvOptions").''; print $langs->trans("Separator").' : '; print htmlentities($separator); @@ -1441,9 +1435,9 @@ if ($step == 5 && $datatoimport) $db->rollback(); // We force rollback because this was just a simulation. // Show OK - if (! count($arrayoferrors) && ! count($arrayofwarnings)) print img_picto($langs->trans("OK"),'tick').' '.$langs->trans("NoError").'

'; - else print $langs->trans("NbOfLinesOK",$nbok).'

'; - + if (! count($arrayoferrors) && ! count($arrayofwarnings)) print '
'.img_picto($langs->trans("OK"),'tick').' '.$langs->trans("NoError").'


'; + else print ''.$langs->trans("NbOfLinesOK",$nbok).'

'; + // Show Errors //var_dump($arrayoferrors); if (count($arrayoferrors)) @@ -1585,7 +1579,7 @@ if ($step == 6 && $datatoimport) print ''; // Module - print ''; + print ''; print ''; // Source file format - print ''; + print ''; print ''; + // Separator and enclosure + if ($model == 'csv') { + print ''; + print ''; + } + // File to import print ''; print ''; print ''; @@ -254,7 +254,7 @@ if ($action == 'create') print ''; print ''; print ''; diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index b0c65b90cbf..a03abce6350 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -86,7 +86,7 @@ if ($filtre) { $sql.= " GROUP BY l.rowid, l.label, l.capital, l.datestart, l.dateend"; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -121,7 +121,9 @@ if ($resql) print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); - print '
'.$langs->trans("Module").'
'.$langs->trans("Module").''; $titleofmodule=$objimport->array_import_module[0]->getName(); // Special cas for import common to module/services @@ -1606,12 +1600,23 @@ if ($step == 6 && $datatoimport) //print '
'.$langs->trans("InformationOnSourceFile").'
'.$langs->trans("SourceFileFormat").'
'.$langs->trans("SourceFileFormat").''; $text=$objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format),$text); print '
'.$langs->trans("CsvOptions").''; + print $langs->trans("Separator").' : '; + print htmlentities($separator); + print '    '.$langs->trans("Enclosure").' : '; + print htmlentities($enclosure); + print '
'.$langs->trans("FileToImport").''; diff --git a/htdocs/install/mysql/data/llx_c_currencies.sql b/htdocs/install/mysql/data/llx_c_currencies.sql index 5b766d2006d..57899dc7ea5 100644 --- a/htdocs/install/mysql/data/llx_c_currencies.sql +++ b/htdocs/install/mysql/data/llx_c_currencies.sql @@ -96,6 +96,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'LVL' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'LBP', '[163]', 1, 'Lebanon Pound'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'LRD', '[36]', 1, 'Liberia Dollar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'LTL', '[76,116]', 1, 'Lithuania Litas'); +INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MGA', NULL, 1, 'Ariary'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MKD', '[1076,1077,1085]', 1, 'Macedonia Denar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MYR', '[82,77]', 1, 'Malaysia Ringgit'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MRO', NULL, 1, 'Mauritania Ouguiya'); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 0a31d3c3159..42ecad2b927 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -33,9 +33,8 @@ -- Visible in misc page insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_NOT_INSTALLED','1','chaine','Setup is running',1,0); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_FEATURES_LEVEL','0','chaine','Level of features to show: -1=stable+deprecated, 0=stable only (default), 1=stable+experimental, 2=stable+experimental+development',1,0); -insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_LOGTOHTML','0','chaine','If this constants is defined, it is possible to have logs inside pages by adding the parameter &logtohtml=1',1,0); insert into llx_const (name, value, type, note, visible, entity) values ('MAILING_LIMIT_SENDBYWEB','25','chaine','Number of targets to defined packet size when sending mass email',1,0); -insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_ENABLE_LOG_TO_HTML','0','chaine','If this option is set to 1, it is possible to see log output at end of HTML sources by adding paramater logtohtml=1 on URL',1,0); +insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_ENABLE_LOG_TO_HTML','0','chaine','If this option is set to 1, it is possible to see log output at end of HTML sources by adding paramater logtohtml=1 on URL. Module log must also be enabled.',1,0); -- Hidden and common to all entities insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_HANDLERS','["mod_syslog_file"]','chaine','Which logger to use',0,0); diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index d5f7f636946..d747d5098f5 100644 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -22,7 +22,7 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); -insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_ENABLE_LOG_TO_HTML','0','chaine','If this option is set to 1, it is possible to see log output at end of HTML sources by adding paramater logtohtml=1 on URL',1,0); +insert into llx_const (name, value, type, note, visible, entity) values (__ENCRYPT('MAIN_ENABLE_LOG_TO_HTML')__,__ENCRYPT('0')__,'chaine','If this option is set to 1, it is possible to see log output at end of HTML sources by adding paramater logtohtml=1 on URL',1,0); -- Was done into a 3.8 fix, so we must do it also in 3.9 @@ -61,7 +61,7 @@ update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+'; INSERT INTO llx_const (name, value, type, note, visible) values (__ENCRYPT('MAIN_DELAY_EXPENSEREPORTS_TO_PAY')__,__ENCRYPT('31')__,'chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0); -INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_SIZE_SHORTLIST_LIMIT','3','chaine','Max length for small lists (tabs)',0); +INSERT INTO llx_const (name, value, type, note, visible) values (__ENCRYPT('MAIN_SIZE_SHORTLISTE_LIMIT')__,__ENCRYPT('3')__,'chaine','Max length for small lists (tabs)',0); ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32); ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32); diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 92f29ceab11..4d653644f39 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -64,6 +64,10 @@ ALTER TABLE llx_website ADD COLUMN virtualhost varchar(255) after fk_default_hom ALTER TABLE llx_chargesociales ADD COLUMN fk_account integer after fk_type; ALTER TABLE llx_chargesociales ADD COLUMN fk_mode_reglement integer after fk_account; +ALTER TABLE llx_chargesociales ADD COLUMN fk_user_author integer; +ALTER TABLE llx_chargesociales ADD COLUMN fk_user_modif integer; +ALTER TABLE llx_chargesociales ADD COLUMN fk_user_valid integer; + ALTER TABLE llx_ecm_files ADD COLUMN gen_or_uploaded varchar(12) after cover; @@ -183,10 +187,16 @@ ALTER TABLE llx_bank_account ADD COLUMN note_public text; ALTER TABLE llx_bank_account ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_bank_account ADD COLUMN import_key varchar(14); +ALTER TABLE llx_projet ADD COLUMN import_key varchar(14); +ALTER TABLE llx_projet_task ADD COLUMN import_key varchar(14); +ALTER TABLE llx_projet_task_time ADD COLUMN import_key varchar(14); + + ALTER TABLE llx_overwrite_trans ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_mailing_cibles ADD COLUMN error_text varchar(255); +ALTER TABLE llx_c_actioncomm MODIFY COLUMN type varchar(50) DEFAULT 'system' NOT NULL; create table llx_user_employment ( @@ -209,6 +219,7 @@ create table llx_user_employment )ENGINE=innodb; + -- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate. drop table tmp_links_double; --select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2; @@ -219,4 +230,5 @@ drop table tmp_links_double; ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label); -ALTER TABLE llx_c_actioncomm MODIFY COLUMN type varchar(50) DEFAULT 'system' NOT NULL; +UPDATE llx_projet_task SET ref = NULL WHERE ref = ''; +ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity); diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 3ba06daabce..d487217cb9a 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -17,7 +17,7 @@ -- ALTER TABLE llx_accountingaccount MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- ALTER TABLE llx_accountingaccount MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; --- You can check with show full columns from llx_accountingaccount; +-- You can check with "show full columns from llx_accountingaccount"; diff --git a/htdocs/install/mysql/tables/llx_chargesociales.sql b/htdocs/install/mysql/tables/llx_chargesociales.sql index 0514811eb15..95ab50661b6 100644 --- a/htdocs/install/mysql/tables/llx_chargesociales.sql +++ b/htdocs/install/mysql/tables/llx_chargesociales.sql @@ -26,6 +26,9 @@ create table llx_chargesociales tms timestamp, date_creation datetime, -- date de creation date_valid datetime, -- date de validation + fk_user_author integer, -- user making creation + fk_user_modif integer, -- user making last change + fk_user_valid integer, -- user validating fk_type integer NOT NULL, fk_account integer, -- bank account fk_mode_reglement integer, -- mode de reglement diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index ab3bbee222e..d50547b711b 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -41,5 +41,6 @@ create table llx_projet --budget_days real, -- budget in days is sum of field planned_workload of tasks opp_amount double(24,8), budget_amount double(24,8), - model_pdf varchar(255) + model_pdf varchar(255), + import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_projet_task.key.sql b/htdocs/install/mysql/tables/llx_projet_task.key.sql index f25d00d5563..620bbc17eaa 100644 --- a/htdocs/install/mysql/tables/llx_projet_task.key.sql +++ b/htdocs/install/mysql/tables/llx_projet_task.key.sql @@ -17,6 +17,7 @@ -- -- ============================================================================ +ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity); ALTER TABLE llx_projet_task ADD INDEX idx_projet_task_fk_projet (fk_projet); ALTER TABLE llx_projet_task ADD INDEX idx_projet_task_fk_user_creat (fk_user_creat); diff --git a/htdocs/install/mysql/tables/llx_projet_task.sql b/htdocs/install/mysql/tables/llx_projet_task.sql index 5b9decd23ef..70ec071be95 100644 --- a/htdocs/install/mysql/tables/llx_projet_task.sql +++ b/htdocs/install/mysql/tables/llx_projet_task.sql @@ -41,5 +41,6 @@ create table llx_projet_task note_private text, note_public text, rang integer DEFAULT 0, - model_pdf varchar(255) + model_pdf varchar(255), + import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_projet_task_time.sql b/htdocs/install/mysql/tables/llx_projet_task_time.sql index 3ca161ed07d..c0b250b6dfc 100644 --- a/htdocs/install/mysql/tables/llx_projet_task_time.sql +++ b/htdocs/install/mysql/tables/llx_projet_task_time.sql @@ -28,5 +28,6 @@ create table llx_projet_task_time thm double(24,8), invoice_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice id here invoice_line_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice line id here + import_key varchar(14), -- Import key note text )ENGINE=innodb; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index cae29217cdb..dcefae7aecb 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -22,6 +22,10 @@ BackToChartofaccounts=Return chart of accounts Chartofaccounts=Chart of accounts CurrentDedicatedAccountingAccount=Current dedicated account AssignDedicatedAccountingAccount=New account to assign +InvoiceLabel=Invoice label +OverviewOfAmountOfLinesNotBound=Overview of amount of lines not bound to accounting account +OverviewOfAmountOfLinesBound=Overview of amount of lines already bound to accounting account +OtherInfo=Other information AccountancyArea=Accountancy area AccountancyAreaDescIntro=Usage of the accountancy module is done in several step: @@ -136,7 +140,7 @@ DelYear=Year to delete DelJournal=Journal to delete ConfirmDeleteMvt=This will delete all lines of the general ledger for year and/or from a specific journal. At least one criteria is required. ConfirmDeleteMvtPartial=This will delete the selected line(s) of the general ledger -DelBookKeeping=Delete the record of the general ledger +DelBookKeeping=Delete record of the general ledger FinanceJournal=Finance journal ExpenseReportsJournal=Expense reports journal DescFinanceJournal=Finance journal including all the types of payments by bank account diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ecc6e8897fc..19f6dfe9d81 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -223,6 +223,16 @@ HelpCenterDesc1=This area can help you to get a Help support service on Dolibarr HelpCenterDesc2=Some part of this service are available in english only. CurrentMenuHandler=Current menu handler MeasuringUnit=Measuring unit +LeftMargin=Left margin +TopMargin=Top margin +PaperSize=Paper type +Orientation=Orientation +SpaceX=Space X +SpaceY=Space Y +FontSize=Font size +Content=Content +NoticePeriod=Notice +NewByMonth=New by month Emails=E-mails EMailsSetup=E-mails setup EMailsDesc=This page allows you to overwrite your PHP parameters for e-mails sending. In most cases on Unix/Linux OS, your PHP setup is correct and these parameters are useless. @@ -366,8 +376,8 @@ ExtrafieldLink=Link to an object ExtrafieldParamHelpselect=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
...

In order to have the list depending on another :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... -ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter -ExtrafieldParamHelpchkbxlst=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpchkbxlst=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax : ObjectName:Classpath
Example : Societe:societe/class/societe.class.php LibraryToBuildPDF=Library used for PDF generation WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir' @@ -815,6 +825,7 @@ DictionaryPaymentModes=Payment modes DictionaryTypeContact=Contact/Address types DictionaryEcotaxe=Ecotax (WEEE) DictionaryPaperFormat=Paper formats +DictionaryFormatCards=Cards formats DictionaryFees=Types of fees DictionarySendingMethods=Shipping methods DictionaryStaff=Staff @@ -1018,7 +1029,6 @@ SimpleNumRefModelDesc=Returns the reference number with format %syymm-nnnn where ShowProfIdInAddress=Show professionnal id with addresses on documents ShowVATIntaInAddress=Hide VAT Intra num with addresses on documents TranslationUncomplete=Partial translation -SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to http://transifex.com/projects/p/dolibarr/. MAIN_DISABLE_METEO=Disable meteo view TestLoginToAPI=Test login to API ProxyDesc=Some features of Dolibarr need to have an Internet access to work. Define here parameters for this. If the Dolibarr server is behind a Proxy server, those parameters tells Dolibarr how to access Internet through it. diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index d4fe1334d20..07a720e6537 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -28,6 +28,10 @@ Reconciliation=Reconciliation RIB=Bank Account Number IBAN=IBAN number BIC=BIC/SWIFT number +SwiftValid=BIC/SWIFT valid +SwiftVNotalid=BIC/SWIFT not valid +IbanValid=BAN valid +IbanNotValid=BAN not valid StandingOrders=Direct Debit orders StandingOrder=Direct debit order AccountStatement=Account statement diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index ca1468b3b09..9ee5510f983 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -487,5 +487,5 @@ ToCreateARecurringInvoiceGene=To generate future invoices regularly and manually ToCreateARecurringInvoiceGeneAuto=If you need to have such invoices generated automatically, ask you administrator to enable and setup module %s. Note that both method (manual and automatic) can be used together with no risk of duplication. DeleteRepeatableInvoice=Delete template invoice ConfirmDeleteRepeatableInvoice=Are your sure you want to delete the template invoice? -CreateOneBillByThird=Create one invoice per third (otherwise, one invoice per order) +CreateOneBillByThird=Create one invoice per third party (otherwise, one invoice per order) BillCreated=%s bill(s) created diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index bd410e7b726..c3bfaa08110 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -200,7 +200,7 @@ BasedOnTwoFirstLettersOfVATNumberBeingDifferentFromYourCompanyCountry=Based on t SameCountryCustomersWithVAT=National customers report BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry=Based on the two first letters of the VAT number being the same as your own company's country code LinkedFichinter=Link to an intervention -ImportDataset_tax_contrib=Import social/fiscal taxes -ImportDataset_tax_vat=Import vat payments +ImportDataset_tax_contrib=Social/fiscal taxes +ImportDataset_tax_vat=Vat payments ErrorBankAccountNotFound=Error: Bank account not found FiscalPeriod=Accounting period diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 1fd7fd56767..0de0d487925 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -26,6 +26,7 @@ DocumentModelStandard=Standard document model for interventions InterventionCardsAndInterventionLines=Interventions and lines of interventions InterventionClassifyBilled=Classify "Billed" InterventionClassifyUnBilled=Classify "Unbilled" +InterventionClassifyDone=Classify "Done" StatusInterInvoiced=Billed ShowIntervention=Show intervention SendInterventionRef=Submission of intervention %s diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 1c1a3bf3245..d036a72186b 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -97,7 +97,7 @@ ToAddRecipientsChooseHere=Add recipients by choosing from the lists NbOfEMailingsReceived=Mass emailings received NbOfEMailingsSend=Mass emailings sent IdRecord=ID record -DeliveryReceipt=Delivery Receipt +DeliveryReceipt=Delivery Ack. YouCanUseCommaSeparatorForSeveralRecipients=You can use the comma separator to specify several recipients. TagCheckMail=Track mail opening TagUnsubscribe=Unsubscribe link @@ -118,6 +118,8 @@ MailSendSetupIs2=You must first go, with an admin account, into menu %sHome - Se MailSendSetupIs3=If you have any questions on how to setup your SMTP server, you can ask to %s. YouCanAlsoUseSupervisorKeyword=You can also add the keyword __SUPERVISOREMAIL__ to have email being sent to the supervisor of user (works only if an email is defined for this supervisor) NbOfTargetedContacts=Current number of targeted contact emails +UseFormatFileEmailToTarget=Imported file must have format email;name;firstname;other +UseFormatInputEmailToTarget=Enter a string with format email;name;firstname;other MailAdvTargetRecipients=Recipients (advanced selection) AdvTgtTitle=Fill input fields to preselect the thirdparties or contacts/addresses to target AdvTgtSearchTextHelp=Use %% as magic caracters. For exemple to find all item like jean, joe, jim, you can input j%%, you can also use ; as separator for value, and use ! for except this value. For exemple jean;joe;jim%%;!jimo;!jima% will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index e5d0a5bb970..c2872ecc8f1 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -322,6 +322,9 @@ AmountTTCShort=Amount (inc. tax) AmountHT=Amount (net of tax) AmountTTC=Amount (inc. tax) AmountVAT=Amount tax +MulticurrencyAlreadyPaid=Already payed, original currency +MulticurrencyRemainderToPay=Remain to pay, original currency +MulticurrencyPaymentAmount=Payment amount, original currency MulticurrencyAmountHT=Amount (net of tax), original currency MulticurrencyAmountTTC=Amount (inc. of tax), original currency MulticurrencyAmountVAT=Amount tax, original currency @@ -613,6 +616,9 @@ NoFileFound=No documents saved in this directory CurrentUserLanguage=Current language CurrentTheme=Current theme CurrentMenuManager=Current menu manager +Browser=Browser +Layout=Layout +Screen=Screen DisabledModules=Disabled modules For=For ForCustomer=For customer @@ -691,6 +697,7 @@ Test=Test Element=Element NoPhotoYet=No pictures available yet Dashboard=Dashboard +MyDashboard=My dashboard Deductible=Deductible from=from toward=toward @@ -743,6 +750,9 @@ Calendar=Calendar GroupBy=Group by... ViewFlatList=View flat list RemoveString=Remove string '%s' +SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to http://transifex.com/projects/p/dolibarr/. +DirectDownloadLink=Direct download link +Download=Download # Week day Monday=Monday Tuesday=Tuesday diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 2f0579394eb..62ffb02bbcf 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -126,29 +126,19 @@ TypeContact_order_supplier_internal_SHIPPING=Representative following-up shippin TypeContact_order_supplier_external_BILLING=Supplier invoice contact TypeContact_order_supplier_external_SHIPPING=Supplier shipping contact TypeContact_order_supplier_external_CUSTOMER=Supplier contact following-up order - Error_COMMANDE_SUPPLIER_ADDON_NotDefined=Constant COMMANDE_SUPPLIER_ADDON not defined Error_COMMANDE_ADDON_NotDefined=Constant COMMANDE_ADDON not defined Error_OrderNotChecked=No orders to invoice selected -# Sources -OrderSource0=Commercial proposal -OrderSource1=Internet -OrderSource2=Mail campaign -OrderSource3=Phone compaign -OrderSource4=Fax campaign -OrderSource5=Commercial -OrderSource6=Store -QtyOrdered=Qty ordered -# Documents models -PDFEinsteinDescription=A complete order model (logo...) -PDFEdisonDescription=A simple order model -PDFProformaDescription=A complete proforma invoice (logo…) -# Orders modes +# Order modes (how we receive order). Not the "why" are keys stored into dict.lang OrderByMail=Mail OrderByFax=Fax OrderByEMail=EMail OrderByWWW=Online OrderByPhone=Phone +# Documents models +PDFEinsteinDescription=A complete order model (logo...) +PDFEdisonDescription=A simple order model +PDFProformaDescription=A complete proforma invoice (logo…) CreateInvoiceForThisCustomer=Bill orders NoOrdersToInvoice=No orders billable CloseProcessedOrdersAutomatically=Classify "Processed" all selected orders. @@ -158,4 +148,5 @@ OrderCreated=Your orders have been created OrderFail=An error happened during your orders creation CreateOrders=Create orders ToBillSeveralOrderSelectCustomer=To create an invoice for several orders, click first onto customer, then choose "%s". -CloseReceivedSupplierOrdersAutomatically=Close order to "%s" automatically if all products are received. \ No newline at end of file +CloseReceivedSupplierOrdersAutomatically=Close order to "%s" automatically if all products are received. +SetShippingMode=Set shipping mode \ No newline at end of file diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 7897d57007d..ecf61d17d36 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -20,8 +20,9 @@ OnlyOpenedProject=Only open projects are visible (projects in draft or closed st ClosedProjectsAreHidden=Closed projects are not visible. TasksPublicDesc=This view presents all projects and tasks you are allowed to read. TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything). -AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task you are assigned on. Assign task to you if you want to enter time on it. -OnlyYourTaskAreVisible=Only tasks you are assigned on are visible. Assign task to you if you want to enter time on it. +AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it. +OnlyYourTaskAreVisible=Only tasks assigned to you are visible. Assign task to yourself if it is not visible and you need to enter time on it. +ImportDatasetTasks=Tasks of projects NewProject=New project AddProject=Create project DeleteAProject=Delete a project diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 0894447d485..2b31ca856bc 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -245,7 +245,7 @@ if ($action == 'create') print '
'.$langs->trans('NotePrivate').''; - $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, 100); + $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); print $doleditor->Create(1); print '
'.$langs->trans('NotePublic').''; - $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, 100); + $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); print $doleditor->Create(1); print '
'; + print '
'; + print '
'."\n"; + print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"l.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"l.label","",$param,'align="left"',$sortfield,$sortorder); @@ -176,6 +178,7 @@ if ($resql) } print "
"; + print ''; print "\n"; $db->free($resql); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 12ed77dd36e..3a9ef61d7ec 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -849,6 +849,7 @@ if (! defined('NOREQUIRETRAN')) $bc=array(0=>'class="impair"',1=>'class="pair"'); $bcdd=array(0=>'class="impair drag drop"',1=>'class="pair drag drop"'); $bcnd=array(0=>'class="impair nodrag nodrop nohover"',1=>'class="pair nodrag nodrop nohoverpair"'); // Used for tr to add new lines +$bctag=array(0=>'class="impair tagtr"',1=>'class="pair tagtr"'); // Define messages variables $mesg=''; $warning=''; $error=0; diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 66ade35e09e..eb3292cd332 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -157,7 +157,7 @@ if (! empty($enddate)) $sql .= " AND d.buy_price_ht IS NOT NULL"; $sql .= $db->order($sortfield, $sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_syslog(__FILE__, LOG_DEBUG); @@ -179,7 +179,10 @@ if ($result) { print '
'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - print ""; + $moreforfilter=''; + + print '
'; + print '
'."\n"; print ''; @@ -244,6 +247,8 @@ if ($result) { } } print "
"; + + print ""; } else { dol_print_error($db); } diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 24150a1050c..88570d1c1d4 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -203,8 +203,11 @@ if ($result) print '
'; print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',0,0,''); + $moreforfilter=''; + $i = 0; - print ""; + print '
'; + print '
'."\n"; print ''; if ($id > 0) { @@ -324,6 +327,7 @@ if ($result) print "\n"; print "
"; + print ''; } else { diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index f6d94fb8135..7550b672007 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -167,6 +167,8 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',0,0,''); $i = 0; + + print '
'; print ''; print ''; @@ -252,7 +254,7 @@ if ($id > 0 || ! empty($ref)) print ''; print "\n"; print "
 
"; - print '
'; + print '
'; } else { dol_print_error($db); } diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index dc0acb48d96..133f1554b49 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -252,7 +252,7 @@ print '
'.$langs->trans("Description") .''; if ($action == 'edit') { - $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120); + $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,'90%'); $doleditor->Create(0,''); } else diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index aed5610bee0..42791f0af8d 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -78,8 +78,6 @@ llxHeader(); $param=''; $fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname'; -print '
'."\n"; - print load_fiche_titre($langs->trans("OpenSurveyArea")); // List of surveys into database @@ -90,7 +88,11 @@ print ''; print ''; print ''; -print ''."\n"; +$moreforfilter = ''; + +print '
'; +print '
'."\n"; + print ''; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.id_sondage",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Title"), $_SERVER["PHP_SELF"], "p.titre",$param,"","",$sortfield,$sortorder); @@ -104,7 +106,7 @@ print ''."\n"; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -122,7 +124,7 @@ $sql.= " u.login, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -197,11 +199,9 @@ while ($i < min($num,$limit)) } print '
'."\n"; - +print '
'; print ''; -print ''."\n"; - llxFooter(); $db->close(); diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 94ec2a7c247..787bb7969fa 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -149,7 +149,7 @@ if (! $_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creati print '
'. $langs->trans("Description") .''; -$doleditor=new DolEditor('commentaires', $_SESSION["commentaires"],'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120); +$doleditor=new DolEditor('commentaires', $_SESSION["commentaires"],'',120,'dolibarr_notes','In',1,1,1,ROWS_7,'90%'); $doleditor->Create(0,''); print '
'; print $langs->trans("MessageOK").''; -$doleditor=new DolEditor('PAYBOX_MESSAGE_OK',$conf->global->PAYBOX_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_2,60); +$doleditor=new DolEditor('PAYBOX_MESSAGE_OK',$conf->global->PAYBOX_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_2,'90%'); $doleditor->Create(); print '
'; print $langs->trans("MessageKO").''; -$doleditor=new DolEditor('PAYBOX_MESSAGE_KO',$conf->global->PAYBOX_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_2,60); +$doleditor=new DolEditor('PAYBOX_MESSAGE_KO',$conf->global->PAYBOX_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_2,'90%'); $doleditor->Create(); print '
'; print $langs->trans("MessageOK").''; -$doleditor=new DolEditor('PAYPAL_MESSAGE_OK',$conf->global->PAYPAL_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_4,60); +$doleditor=new DolEditor('PAYPAL_MESSAGE_OK',$conf->global->PAYPAL_MESSAGE_OK,'',100,'dolibarr_details','In',false,true,true,ROWS_4,'90%'); $doleditor->Create(); print '
'; print $langs->trans("MessageKO").''; -$doleditor=new DolEditor('PAYPAL_MESSAGE_KO',$conf->global->PAYPAL_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_4,60); +$doleditor=new DolEditor('PAYPAL_MESSAGE_KO',$conf->global->PAYPAL_MESSAGE_KO,'',100,'dolibarr_details','In',false,true,true,ROWS_4,'90%'); $doleditor->Create(); print '
'.$form->textwithpicto($langs->trans("Parameters"),$help,1).''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('parameters',empty($price_updaters->parameters)?'':$price_updaters->parameters,'',300,'','',false,false,false,10,80); + $doleditor=new DolEditor('parameters',empty($price_updaters->parameters)?'':$price_updaters->parameters,'',300,'','',false,false,false,ROWS_8,'90%'); $doleditor->Create(); print '
'; + print '
'; + print ''; $tmpcode=''; if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$type); - print ''; // Label - print ''; + print ''; // On sell print ''; } // Description (used in invoice, propal...) print '"; @@ -967,11 +968,11 @@ else if ($type != 1 && ! empty($conf->stock->enabled)) { print ''; // Stock desired level print ''; } else @@ -1043,7 +1044,7 @@ else // Custom code if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) { - print ''; + print ''; // Origin country print '"; @@ -1093,18 +1094,18 @@ else print '
'.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; if ($refalreadyexists) { print $langs->trans("RefAlreadyExists"); @@ -903,7 +904,7 @@ else print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; @@ -946,14 +947,14 @@ else print ''.$langs->trans("BarcodeValue").''; $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); - print ''; + print ''; print '
'.$langs->trans("Description").''; - $doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, '80%'); + $doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); $doleditor->Create(); print "
'.$langs->trans("StockLimit").''; - print ''; + print ''; print ''.$langs->trans("DesiredStock").''; - print ''; + print ''; print '
'.$langs->trans("CustomCode").'
'.$langs->trans("CustomCode").''.$langs->trans("CountryOrigin").''; print $form->select_country(GETPOST('country_id','int'),'country_id'); @@ -1065,7 +1066,7 @@ else print '
'.$langs->trans("NoteNotVisibleOnBill").''; // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. - $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 8, '80%'); + $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8, '90%'); $doleditor->Create(); print "
'; // Price - print ''; - print ''; + print ''; // Min price print ''; - print ''; // VAT - print ''; @@ -1113,32 +1114,33 @@ else print '
'; } + // Accountancy codes print '
'.$langs->trans("SellingPrice").''; + print '
'.$langs->trans("SellingPrice").''; print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); print '
'.$langs->trans("MinPrice").''; + print ''; print '
'.$langs->trans("VATRate").''; + print '
'.$langs->trans("VATRate").''; print $form->load_tva("tva_tx",-1,$mysoc,''); print '
'; if (! empty($conf->accounting->enabled)) { // Accountancy_code_sell print ''; - print ''; // Accountancy_code_buy print ''; - print ''; } else // For external software { // Accountancy_code_sell print ''; - print ''; // Accountancy_code_buy print ''; - print ''; } print '
'.$langs->trans("ProductAccountancySellCode").''; - print $formaccountancy->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 0, 1); + print ''; + print $formaccountancy->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancyBuyCode").''; - print $formaccountancy->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 0, 1); + print ''; + print $formaccountancy->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancySellCode").''; + print ''; print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print ''; print '
'; @@ -1185,10 +1187,10 @@ else print ''; // Ref - print ''; + print ''; // Label - print ''; + print ''; // Status To sell print '"; @@ -1356,7 +1358,7 @@ else // Custom code if (! $object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) { - print ''; + print ''; // Origin country print '"; @@ -1406,13 +1408,13 @@ else if (! empty($conf->accounting->enabled)) { // Accountancy_code_sell - print ''; + print ''; print ''; // Accountancy_code_buy - print ''; + print ''; print ''; @@ -1420,13 +1422,13 @@ else else // For external software { // Accountancy_code_sell - print ''; - print ''; + print ''; // Accountancy_code_buy - print ''; - print ''; + print ''; } print '
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; @@ -1260,7 +1262,7 @@ else print '
'.$langs->trans("Description").''; // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. - $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); + $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); $doleditor->Create(); print "
'.$langs->trans("CustomCode").'
'.$langs->trans("CustomCode").''.$langs->trans("CountryOrigin").''; print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); @@ -1391,7 +1393,7 @@ else { print '
'.$langs->trans("NoteNotVisibleOnBill").''; - $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); + $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); $doleditor->Create(); print "
'.$langs->trans("ProductAccountancySellCode").'
'.$langs->trans("ProductAccountancySellCode").''; print $formaccountancy->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancyBuyCode").'
'.$langs->trans("ProductAccountancyBuyCode").''; print $formaccountancy->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancySellCode").''; + print '
'.$langs->trans("ProductAccountancySellCode").''; print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; print '
'; @@ -1483,10 +1485,13 @@ else if (($action != 'editbarcodetype') && ! empty($user->rights->produit->creer) && $createbarcode) print '
id.'">'.img_edit($langs->trans('Edit'),1).'
'; print ''; - if ($action == 'editbarcodetype') + if ($action == 'editbarcodetype' || $action == 'editbarcode') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); + } + if ($action == 'editbarcodetype') + { $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); } else @@ -1506,13 +1511,16 @@ else print ''; if ($action == 'editbarcode') { - print ''; - print ''; - print ''; - print ''; - print ''; - print ' '; - print ''; + $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; + if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ' '; + print '
'; } else { diff --git a/htdocs/product/class/api_deprecated_product.class.php b/htdocs/product/class/api_deprecated_product.class.php index d4ad8335f54..cdda0c45fbb 100644 --- a/htdocs/product/class/api_deprecated_product.class.php +++ b/htdocs/product/class/api_deprecated_product.class.php @@ -126,7 +126,7 @@ class ProductApi extends DolibarrApi // Show product on buy if ($to_buy) $sql.= " AND p.to_buy = ".$db->escape($to_buy); - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -212,7 +212,7 @@ class ProductApi extends DolibarrApi // Show product on buy if ($to_buy) $sql.= " AND p.to_buy = ".$db->escape($to_buy); - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -307,6 +307,7 @@ class ProductApi extends DolibarrApi } foreach($request_data as $field => $value) { + if ($field == 'id') continue; $this->product->$field = $value; } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 290d011d09c..0c08fb0dc35 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -213,6 +213,7 @@ class Products extends DolibarrApi } foreach($request_data as $field => $value) { + if ($field == 'id') continue; $this->product->$field = $value; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4af929b8cba..bb122dc70e8 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -924,7 +924,23 @@ class Product extends CommonObject if ($result < 0) { $error++; } // End call triggers } - + + // Delete from product_batch on product delete + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch'; + $sql.= " WHERE fk_product_stock IN ("; + $sql.= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; + $sql.= " WHERE fk_product = ".$id.")"; + dol_syslog(get_class($this).'::delete', LOG_DEBUG); + $result = $this->db->query($sql); + if (! $result) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + // Delete all child tables if (! $error) { @@ -2168,7 +2184,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = cd.fk_contrat"; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contrat', 1).")"; + $sql.= " AND c.entity IN (".getEntity('contract', 1).")"; $sql.= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; //$sql.= " AND c.statut != 0"; @@ -2794,7 +2810,7 @@ class Product extends CommonObject $list = array(); - $sql = "SELECT p.fk_soc"; + $sql = "SELECT DISTINCT p.fk_soc"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p"; $sql.= " WHERE p.fk_product = ".$this->id; $sql.= " AND p.entity = ".$conf->entity; diff --git a/htdocs/product/dynamic_price/editor.php b/htdocs/product/dynamic_price/editor.php index 9b20371ea5b..0b93d17749a 100644 --- a/htdocs/product/dynamic_price/editor.php +++ b/htdocs/product/dynamic_price/editor.php @@ -199,7 +199,7 @@ foreach ($price_globals->listGlobalVariables() as $entry) { //Price expression editor print ''.$form->textwithpicto($langs->trans("PriceExpressionEditor"),$help_text,1).''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$doleditor=new DolEditor('expression',isset($price_expression->expression)?$price_expression->expression:'','',300,'','',false,false,false,4,80); +$doleditor=new DolEditor('expression',isset($price_expression->expression)?$price_expression->expression:'','',300,'','',false,false,false,ROWS_4,'90%'); $doleditor->Create(); print ''; print ''; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 05d70e7eb26..a71db876dd0 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -587,7 +587,8 @@ if ($id > 0 || $ref) if ($user->rights->fournisseur->lire) { // Suppliers list title - print ''; + print '
'; + print '
'; if ($object->isProduct()) $nblignefour=4; else $nblignefour=4; @@ -713,6 +714,7 @@ if ($id > 0 || $ref) } print '
'; + print ''; } } } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 3e2f21e4ecd..24df0f65715 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -304,7 +304,7 @@ else $sql.=$hookmanager->resPrint; //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet $sql.= $db->order($sortfield,$sortorder); - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -439,7 +439,8 @@ else $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print ''; + print '
'; + print '
'."\n"; print ''; if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); @@ -839,6 +840,7 @@ else $db->free($resql); print "
"; + print ""; } print ''; } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 4e04a4c626a..8f1e7484ced 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -959,7 +959,7 @@ else } } if ($action != 'edit_price_by_qty') { - print '
'; + print ''; // FIXME a form into a table is not allowed print ''; print ''; print ''; @@ -1345,6 +1345,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"),'','','','','',$backbutton, 0, 0, 'title_accountancy.png'); else print_barre_liste($langs->trans("PriceByCustomerLog"),'','','','','','', 0, 0, 'title_accountancy.png'); + print '
'; print ''; print ''; @@ -1450,6 +1451,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ $db->free($result); print "
"; + print '
'; print "
"; } } else { @@ -1659,7 +1661,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int')); // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); } @@ -1739,7 +1741,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // List of all prices by customers // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all($sortorder, $sortfield, 0, 0, $filter); } diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index b193e553b61..13bc0fef186 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -86,7 +86,7 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $sref=""; $snom=""; @@ -261,6 +261,7 @@ if ($resql) $colspan_warehouse = 1; if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse+1 : 1; } + print '
'; print ''; // Lignes des titres @@ -381,6 +382,7 @@ if ($resql) } print "
"; + print '
'; print '
'; if ($num > $conf->liste_limit) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index c9619124389..471aa7e3e6d 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -83,7 +83,7 @@ if (! empty($canvas)) * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $sref=""; $snom=""; @@ -249,7 +249,8 @@ if ($resql) /*if ($eatby) $param.="&eatby=".$eatby; if ($sellby) $param.="&sellby=".$sellby;*/ - print ''; + print '
'; + print '
'; // Lignes des titres print ""; @@ -381,6 +382,7 @@ if ($resql) } print "
"; + print ''; print ''; if ($num > $conf->liste_limit) diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index f9b9d14d794..192017af2a5 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -193,7 +193,8 @@ if ($id > 0 || ! empty($ref)) print ''; $i = 0; - print ''; + print '
'; + print '
'; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid","",$option,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$option,'',$sortfield,$sortorder); @@ -243,8 +244,8 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print "
'.price($total_ht).'
"; + print ""; print ''; - print '
'; } else { dol_print_error($db); } diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 4bdfdcc5c81..bed3be1892f 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -72,6 +72,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { $search_year = ''; } + /* * View */ @@ -203,6 +204,7 @@ if ($id > 0 || ! empty($ref)) { print ''; $i = 0; + print '
'; print ''; print ''; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid", "", $option, '', $sortfield, $sortorder); @@ -251,8 +253,8 @@ if ($id > 0 || ! empty($ref)) { print ''; print ''; print "
' . price($total_ht) . '
"; + print '
'; print ''; - print '
'; } else { dol_print_error($db); } diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index ff91fbf299e..8c5f1a3ba86 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -123,7 +123,7 @@ if ($id > 0 || ! empty($ref)) $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " WHERE c.rowid = cd.fk_contrat"; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contrat', 1).")"; + $sql.= " AND c.entity IN (".getEntity('contract', 1).")"; $sql.= " AND cd.fk_product =".$product->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; @@ -135,10 +135,27 @@ if ($id > 0 || ! empty($ref)) if ($result) { $num = $db->num_rows($result); - + if (! empty($id)) + $option .= '&id=' . $product->id; + if (! empty($search_month)) + $option .= '&search_month=' . $search_month; + if (! empty($search_year)) + $option .= '&search_year=' . $search_year; + + print '
' . "\n"; + if (! empty($sortfield)) + print ''; + if (! empty($sortorder)) + print ''; + if (! empty($page)) { + print ''; + $option .= '&page=' . $page; + } + print_barre_liste($langs->trans("Contrats"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); $i = 0; + print '
'; print ''; print ''; @@ -180,13 +197,15 @@ if ($id > 0 || ! empty($ref)) $i++; } } + + print '
'; + print '
'; + print '
'; } else { dol_print_error($db); } - print ""; - print '
'; $db->free($result); } } diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index e9eb3d41859..53e5b0ab0a6 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -216,6 +216,7 @@ if ($id > 0 || ! empty($ref)) print ''; $i = 0; + print '
'; print ''; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$option,'',$sortfield,$sortorder); @@ -265,8 +266,8 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print "
'.price($total_ht).'
"; + print '
'; print ''; - print '
'; } else { dol_print_error($db); } diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 77bd4b73887..6fe189c7700 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -195,6 +195,7 @@ if ($id > 0 || ! empty($ref)) print ''; $i = 0; + print '
'; print ''; print ''; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); @@ -244,8 +245,8 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print "
' . price($total_ht) . '
"; + print '
'; print ''; - print '
'; } else { dol_print_error($db); } diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index d23853c174f..289cf3d3578 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -197,6 +197,7 @@ if ($id > 0 || ! empty($ref)) print ''; $i = 0; + print '
'; print ''; print ''; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.rowid", "", $option, '', $sortfield, $sortorder); @@ -238,19 +239,20 @@ if ($id > 0 || ! empty($ref)) } } } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "
' . $langs->trans('Total') . '' . $total_qty . '' . price($total_ht) . '
"; - print ''; - print '
'; - } else { - dol_print_error($db); - } - $db->free($result); + + print ''; + print '' . $langs->trans('Total') . ''; + print ''; + print '' . $total_qty . ''; + print '' . price($total_ht) . ''; + print ''; + print ""; + print '
'; + print ''; + } else { + dol_print_error($db); + } + $db->free($result); } } } else { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index f1097b331b9..ad6ea9d6560 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -204,7 +204,7 @@ if ($action == 'create') print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('desc',(!empty($object->description)?$object->description:''),'',180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,5,70); + $doleditor=new DolEditor('desc',(!empty($object->description)?$object->description:''),'',180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,ROWS_5,'90%'); $doleditor->Create(); print ''; @@ -332,7 +332,8 @@ else // Nb of products print ''.$langs->trans("NumberOfProducts").''; - print empty($calcproducts['nb'])?'0':$calcproducts['nb']; + $valtoshow=price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow)?'0':$valtoshow; print ""; print ''; @@ -485,13 +486,19 @@ else $productstatic->entity=$objp->entity; print $productstatic->getNomUrl(1,'stock',16); print ''; + + // Label print ''.$objp->produit.''; - print ''.$objp->value.''; + print ''; + $valtoshow=price2num($objp->value, 'MS'); + print empty($valtoshow)?'0':$valtoshow; + print ''; $totalunit+=$objp->value; // Price buy PMP print ''.price(price2num($objp->ppmp,'MU')).''; + // Total PMP print ''.price(price2num($objp->ppmp*$objp->value,'MT')).''; $totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); @@ -530,7 +537,10 @@ else $db->free($resql); print ''.$langs->trans("Total").''; - print ''.$totalunit.''; + print ''; + $valtoshow=price2num($totalunit, 'MS'); + print empty($valtoshow)?'0':$valtoshow; + print ''; print ' '; print ''.price(price2num($totalvalue,'MT')).''; if (empty($conf->global->PRODUIT_MULTIPRICES)) @@ -583,7 +593,7 @@ else print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('desc',$object->description,'',180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,5,70); + $doleditor=new DolEditor('desc',$object->description,'',180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,ROWS_5,'90%'); $doleditor->Create(); print ''; diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php new file mode 100644 index 00000000000..a246e7fc135 --- /dev/null +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -0,0 +1,350 @@ + + * + * 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 . + */ + +use Luracast\Restler\RestException; + +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + + +/** + * API class for stock movements + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class StockMovements extends DolibarrApi +{ + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'product_id', + 'warehouse_id', + 'qty' + ); + + /** + * @var MouvmeentStock $stockmovement {@type MouvementStock} + */ + public $stockmovement; + + /** + * Constructor + */ + function __construct() + { + global $db, $conf; + $this->db = $db; + $this->stockmovement = new MouvementStock($this->db); + } + + /** + * Get properties of a stock movement object + * + * Return an array with stock movement informations + * + * @param int $id ID of movement + * @return array|mixed data without useless information + * + * @throws RestException + */ + /* + function get($id) + { + if(! DolibarrApiAccess::$user->rights->stock->lire) { + throw new RestException(401); + } + + $result = $this->stockmovement->fetch($id); + if( ! $result ) { + throw new RestException(404, 'warehouse not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->stockmovement->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->stockmovement); + }*/ + + /** + * Get a list of stock movement + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.product_id:=:1) and (t.date_creation:<:'20160101')" + * @return array Array of warehouse objects + * + * @throws RestException + */ + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') { + global $db, $conf; + + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->stock->lire) { + throw new RestException(401); + } + + $sql = "SELECT t.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as t"; + //$sql.= ' WHERE t.entity IN ('.getEntity('stock', 1).')'; + $sql.= ' WHERE 1 = 1'; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + if ($result) + { + $i=0; + $num = $db->num_rows($result); + while ($i < min($num, ($limit <= 0 ? $num : $limit))) + { + $obj = $db->fetch_object($result); + $stockmovement_static = new MouvementStock($db); + if($stockmovement_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($stockmovement_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve stock movement list : '.$stockmovement_static->error); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No stock movement found'); + } + return $obj_ret; + } + +/* + * @param int $product_id Id product id {@min 1} + * @param int $warehouse_id Id warehouse {@min 1} + * @param float $qty Qty to add (Use negative value for a stock decrease) {@min 0} {@message qty must be higher than 0} + * @param string $lot Lot + * @param string $movementcode Movement code {@example INV123} + * @param string $movementlabel Movement label {@example Inventory number 123} + * @param string $price To update AWP (Average Weighted Price) when you make a stock increase (qty must be higher then 0). + */ + + + /** + * Create stock movement object. + * You can use the following message to test this RES API: + * { "product_id": 1, "warehouse_id": 1, "qty": 1, "lot": "", "movementcode": "INV123", "movementlabel": "Inventory 123", "price": 0 } + * + * @param array $request_data Request data + * @return int ID of stock movement + */ + //function post($product_id, $warehouse_id, $qty, $lot='', $movementcode='', $movementlabel='', $price=0) + function post($request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->stock->creer) { + throw new RestException(401); + } + + // Check mandatory fields + //$result = $this->_validate($request_data); + + foreach($request_data as $field => $value) { + //$this->stockmovement->$field = $value; + if ($field == 'product_id') $product_id = $value; + if ($field == 'warehouse_id') $warehouse_id = $value; + if ($field == 'qty') $qty = $value; + if ($field == 'lot') $lot = $value; + if ($field == 'movementcode') $movementcode = $value; + if ($field == 'movementlabel') $movementlabel = $value; + if ($field == 'price') $price = $value; + } + + // Type increase or decrease + if ($qty >= 0) $type = 3; + else $type = 2; + + if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', '', '', $lot) <= 0) { + throw new RestException(503, 'Error when create stock movement : '.$this->stockmovement->error); + } + + return $this->stockmovement->id; + } + + /** + * Update stock movement + * + * @param int $id Id of warehouse to update + * @param array $request_data Datas + * @return int + */ + /* + function put($id, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->stock->creer) { + throw new RestException(401); + } + + $result = $this->stockmovement->fetch($id); + if( ! $result ) { + throw new RestException(404, 'stock movement not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach($request_data as $field => $value) { + if ($field == 'id') continue; + $this->stockmovement->$field = $value; + } + + if($this->stockmovement->update($id, DolibarrApiAccess::$user)) + return $this->get ($id); + + return false; + }*/ + + /** + * Delete stock movement + * + * @param int $id Stock movement ID + * @return array + */ + /* + function delete($id) + { + if(! DolibarrApiAccess::$user->rights->stock->supprimer) { + throw new RestException(401); + } + $result = $this->stockmovement->fetch($id); + if( ! $result ) { + throw new RestException(404, 'stock movement not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (! $this->stockmovement->delete(DolibarrApiAccess::$user)) { + throw new RestException(401,'error when delete stock movement'); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Warehouse deleted' + ) + ); + }*/ + + + + /** + * Clean sensible object datas + * + * @param MouvementStock $object Object to clean + * @return array Array of cleaned object properties + * + * @todo use an array for properties to clean + * + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + // Remove useless data + unset($object->civility_id); + unset($object->firstname); + unset($object->lastname); + unset($object->name); + unset($object->location_incoterms); + unset($object->libelle_incoterms); + unset($object->fk_incoterms); + unset($object->lines); + unset($object->total_ht); + unset($object->total_ttc); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->note); + unset($object->note_private); + unset($object->note_public); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->modelpdf); + unset($object->fk_delivery_address); + unset($object->cond_reglement); + unset($object->cond_reglement_id); + unset($object->mode_reglement_id); + unset($object->barcode_type_coder); + unset($object->barcode_type_label); + unset($object->barcode_type_code); + unset($object->barcode_type); + unset($object->country_code); + unset($object->country_id); + unset($object->country); + unset($object->thirdparty); + unset($object->contact); + unset($object->contact_id); + unset($object->user); + unset($object->fk_project); + unset($object->project); + + //unset($object->eatby); Filled correctly in read mode + //unset($object->sellby); Filled correctly in read mode + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + function _validate($data) + { + $stockmovement = array(); + foreach (Warehouses::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $stockmovement[$field] = $data[$field]; + } + return $stockmovement; + } +} diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php new file mode 100644 index 00000000000..79eefc821c3 --- /dev/null +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -0,0 +1,282 @@ + + * + * 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 . + */ + + use Luracast\Restler\RestException; + + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + +/** + * API class for warehouses + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class Warehouses extends DolibarrApi +{ + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'label', + ); + + /** + * @var Entrepot $warehouse {@type Entrepot} + */ + public $warehouse; + + /** + * Constructor + */ + function __construct() + { + global $db, $conf; + $this->db = $db; + $this->warehouse = new Entrepot($this->db); + } + + /** + * Get properties of a warehouse object + * + * Return an array with warehouse informations + * + * @param int $id ID of warehouse + * @return array|mixed data without useless information + * + * @throws RestException + */ + function get($id) + { + if(! DolibarrApiAccess::$user->rights->stock->lire) { + throw new RestException(401); + } + + $result = $this->warehouse->fetch($id); + if( ! $result ) { + throw new RestException(404, 'warehouse not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->warehouse->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->warehouse); + } + + /** + * List warehouses + * + * Get a list of warehouses + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'WH-%') and (t.date_creation:<:'20160101')" + * @return array Array of warehouse objects + * + * @throws RestException + */ + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') { + global $db, $conf; + + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->stock->lire) { + throw new RestException(401); + } + + $sql = "SELECT t.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as t"; + $sql.= ' WHERE t.entity IN ('.getEntity('stock', 1).')'; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + if ($result) + { + $i=0; + $num = $db->num_rows($result); + while ($i < min($num, ($limit <= 0 ? $num : $limit))) + { + $obj = $db->fetch_object($result); + $warehouse_static = new Entrepot($db); + if($warehouse_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($warehouse_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve warehouse list : '.$warehouse_static->error); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No warehouse found'); + } + return $obj_ret; + } + + + /** + * Create warehouse object + * + * @param array $request_data Request data + * @return int ID of warehouse + */ + function post($request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->stock->creer) { + throw new RestException(401); + } + + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach($request_data as $field => $value) { + $this->warehouse->$field = $value; + } + if($this->warehouse->create(DolibarrApiAccess::$user) <= 0) { + throw new RestException(503, 'Error when create warehouse : '.$this->warehouse->error); + } + return $this->warehouse->id; + } + + /** + * Update warehouse + * + * @param int $id Id of warehouse to update + * @param array $request_data Datas + * @return int + */ + function put($id, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->stock->creer) { + throw new RestException(401); + } + + $result = $this->warehouse->fetch($id); + if( ! $result ) { + throw new RestException(404, 'warehouse not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('stock',$this->warehouse->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach($request_data as $field => $value) { + if ($field == 'id') continue; + $this->warehouse->$field = $value; + } + + if($this->warehouse->update($id, DolibarrApiAccess::$user)) + return $this->get ($id); + + return false; + } + + /** + * Delete warehouse + * + * @param int $id Warehouse ID + * @return array + */ + function delete($id) + { + if(! DolibarrApiAccess::$user->rights->stock->supprimer) { + throw new RestException(401); + } + $result = $this->warehouse->fetch($id); + if( ! $result ) { + throw new RestException(404, 'warehouse not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('stock',$this->warehouse->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (! $this->warehouse->delete(DolibarrApiAccess::$user)) { + throw new RestException(401,'error when delete warehouse'); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Warehouse deleted' + ) + ); + } + + + /** + * Clean sensible object datas + * + * @param Entrepot $object Object to clean + * @return array Array of cleaned object properties + * + * @todo use an array for properties to clean + * + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + // Remove the subscriptions because they are handled as a subresource. + //unset($object->subscriptions); + + return $object; + } + + + /** + * Validate fields before create or update object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + function _validate($data) + { + $warehouse = array(); + foreach (Warehouses::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $warehouse[$field] = $data[$field]; + } + return $warehouse; + } +} diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 2f5af64da96..36599833c2d 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -173,11 +173,15 @@ class Entrepot extends CommonObject */ function update($id, $user) { + if (empty($id)) $id = $this->id; + // Check if new parent is already a child of current warehouse - if(!empty($this->fk_parent)) { + if(!empty($this->fk_parent)) + { $TChildWarehouses = array($id); $TChildWarehouses = $this->get_children_warehouses($this->id, $TChildWarehouses); - if(in_array($this->fk_parent, $TChildWarehouses)) { + if(in_array($this->fk_parent, $TChildWarehouses)) + { $this->error = 'ErrorCannotAddThisParentWarehouse'; return -2; } @@ -189,13 +193,13 @@ class Entrepot extends CommonObject $this->lieu=trim($this->lieu); $this->address=trim($this->address); - $this->zip=trim($this->zip); - $this->town=trim($this->town); - $this->country_id=($this->country_id > 0 ? $this->country_id : $this->country_id); + $this->zip=trim($this->zip); + $this->town=trim($this->town); + $this->country_id=($this->country_id > 0 ? $this->country_id : 0); $sql = "UPDATE ".MAIN_DB_PREFIX."entrepot "; $sql .= " SET label = '" . $this->db->escape($this->libelle) ."'"; - $sql .= ", fk_parent = '" . (($this->fk_parent > 0) ? $this->fk_parent : 'NULL') ."'"; + $sql .= ", fk_parent = " . (($this->fk_parent > 0) ? $this->fk_parent : 'NULL'); $sql .= ", description = '" . $this->db->escape($this->description) ."'"; $sql .= ", statut = " . $this->statut; $sql .= ", lieu = '" . $this->db->escape($this->lieu) ."'"; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 1532f62aa22..dee344b6a5b 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -30,11 +30,32 @@ */ class MouvementStock extends CommonObject { - var $product_id; - var $entrepot_id; - var $qty; - var $type; + /** + * @var string Id to identify managed objects + */ + public $element = 'stockmouvement'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'stock_mouvement'; + + public $product_id; + public $warehouse_id; + public $qty; + public $type; + + public $tms = ''; + public $datem = ''; + public $price; + public $fk_user_author; + public $label; + public $fk_origin; + public $origintype; + public $inventorycode; + public $batch; + + /** * Constructor @@ -46,6 +67,7 @@ class MouvementStock extends CommonObject $this->db = $db; } + /** * Add a movement of stock (in one direction only) * @@ -54,18 +76,18 @@ class MouvementStock extends CommonObject * @param int $entrepot_id Id of warehouse * @param int $qty Qty of movement (can be <0 or >0 depending on parameter type) * @param int $type Direction of movement: - * 0=input (stock increase after stock transfert), 1=output (stock decrease after stock transfer), + * 0=input (stock increase by a stock transfer), 1=output (stock decrease after by a stock transfer), * 2=output (stock decrease), 3=input (stock increase) * Note that qty should be > 0 with 0 or 3, < 0 with 1 or 2. * @param int $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed. * @param string $label Label of stock movement * @param string $inventorycode Inventory code * @param string $datem Force date of movement - * @param date $eatby eat-by date - * @param date $sellby sell-by date + * @param date $eatby eat-by date. Will be used if lot does not exists yet and will be created. + * @param date $sellby sell-by date. Will be used if lot does not exists yet and will be created. * @param string $batch batch number * @param boolean $skip_batch If set to true, stock movement is done without impacting batch record - * @param int $id_product_batch Id product_batch (when skip_batch is flase and we already know which record of product_batch to use) + * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) * @return int <0 if KO, 0 if fk_product is null, >0 if OK */ function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $inventorycode='', $datem='',$eatby='',$sellby='',$batch='',$skip_batch=false, $id_product_batch=0) @@ -75,7 +97,7 @@ class MouvementStock extends CommonObject require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; $error = 0; - dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.", eatby=".$eatby.", sellby=".$sellby.", batch=".$batch.", skip_batch=".$skip_batch); + dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse_id=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.", eatby=".$eatby.", sellby=".$sellby.", batch=".$batch.", skip_batch=".$skip_batch); // Clean parameters if (empty($price)) $price=0; @@ -90,7 +112,7 @@ class MouvementStock extends CommonObject } if ($sellby < 0) { - $this->errors[]='ErrorBadValueForParameterEatBy'; + $this->errors[]='ErrorBadValueForParameterSellBy'; return -1; } @@ -315,7 +337,7 @@ class MouvementStock extends CommonObject $sql.= " '".$origintype."'"; $sql.= ")"; - dol_syslog(get_class($this)."::_create", LOG_DEBUG); + dol_syslog(get_class($this)."::_create insert record into stock_mouvement", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -340,7 +362,7 @@ class MouvementStock extends CommonObject $sql = "SELECT rowid, reel FROM ".MAIN_DB_PREFIX."product_stock"; $sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; // This is a unique key - dol_syslog(get_class($this)."::_create", LOG_DEBUG); + dol_syslog(get_class($this)."::_create check if a record already exists in product_stock", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -405,7 +427,7 @@ class MouvementStock extends CommonObject $sql.= " (".$qty.", ".$entrepot_id.", ".$fk_product.")"; } - dol_syslog(get_class($this)."::_create", LOG_DEBUG); + dol_syslog(get_class($this)."::_create update stock value", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { @@ -444,7 +466,7 @@ class MouvementStock extends CommonObject $sql.= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $sql.= " WHERE rowid = ".$fk_product; - dol_syslog(get_class($this)."::_create", LOG_DEBUG); + dol_syslog(get_class($this)."::_create update AWP", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { @@ -487,6 +509,96 @@ class MouvementStock extends CommonObject } } + + + /** + * Load object in memory from the database + * + * @param int $id Id object + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + $sql .= " t.tms,"; + $sql .= " t.datem,"; + $sql .= " t.fk_product,"; + $sql .= " t.fk_entrepot,"; + $sql .= " t.value,"; + $sql .= " t.price,"; + $sql .= " t.type_mouvement,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.label,"; + $sql .= " t.fk_origin,"; + $sql .= " t.origintype,"; + $sql .= " t.inventorycode,"; + $sql .= " t.batch,"; + $sql .= " t.eatby,"; + $sql .= " t.sellby"; + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql.= ' WHERE 1 = 1'; + //if (null !== $ref) { + //$sql .= ' AND t.ref = ' . '\'' . $ref . '\''; + //} else { + $sql .= ' AND t.rowid = ' . $id; + //} + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->product_id = $obj->fk_product; + $this->warehouse_id = $obj->fk_entrepot; + $this->qty = $obj->value; + $this->type = $obj->type_mouvement; + + $this->tms = $this->db->jdate($obj->tms); + $this->datem = $this->db->jdate($obj->datem); + $this->price = $obj->price; + $this->fk_user_author = $obj->fk_user_author; + $this->label = $obj->label; + $this->fk_origin = $obj->fk_origin; + $this->origintype = $obj->origintype; + $this->inventorycode = $obj->inventorycode; + $this->batch = $obj->batch; + $this->eatby = $this->db->jdate($obj->eatby); + $this->sellby = $this->db->jdate($obj->sellby); + } + + // Retrieve all extrafields for invoice + // fetch optionals attributes and labels + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + + // $this->fetch_lines(); + + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + + /** * Create movement in database for all subproducts @@ -545,18 +657,18 @@ class MouvementStock extends CommonObject /** * Decrease stock for product and subproducts * - * @param User $user Object user - * @param int $fk_product Id product - * @param int $entrepot_id Warehouse id - * @param int $qty Quantity - * @param int $price Price - * @param string $label Label of stock movement - * @param string $datem Force date of movement - * @param date $eatby eat-by date - * @param date $sellby sell-by date - * @param string $batch batch number + * @param User $user Object user + * @param int $fk_product Id product + * @param int $entrepot_id Warehouse id + * @param int $qty Quantity + * @param int $price Price + * @param string $label Label of stock movement + * @param string $datem Force date of movement + * @param date $eatby eat-by date + * @param date $sellby sell-by date + * @param string $batch batch number * @param int $id_product_batch Id product_batch - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='', $eatby='', $sellby='', $batch='', $id_product_batch=0) { @@ -592,8 +704,10 @@ class MouvementStock extends CommonObject * * @param int $id Id of product * @return int <0 if KO, nb of subproducts if OK + * @deprecated A count($product->getChildsArbo($id,1)) is same. No reason to have this in this class. */ - function nbOfSubProdcuts($id) + /* + function nbOfSubProducts($id) { $nbSP=0; @@ -605,7 +719,7 @@ class MouvementStock extends CommonObject $nbSP=$obj->nb; } return $nbSP; - } + }*/ /** * Count number of product in stock before a specific date diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 453f49f0c33..0bfd9048352 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -146,7 +146,8 @@ if ($result) $moreforfilter=''; - print ''; + print '
'; + print '
'."\n"; print ""; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder); @@ -250,7 +251,8 @@ if ($result) $db->free($result); print "
"; - + print ""; + print ''; } else diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 7d80032e1d9..e2cb108f87d 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -162,8 +162,8 @@ if ($action == "correct_stock") //$eatby=GETPOST('eatby'); //$sellby=GETPOST('sellby'); - $eatby=dol_mktime(12, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); - $sellby=dol_mktime(12, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); + $eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); + $sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); $result=$product->correct_stock_batch( $user, @@ -456,7 +456,7 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // No $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -534,7 +534,8 @@ if ($resql) // Nb of products print ''.$langs->trans("NumberOfProducts").''; - print empty($calcproducts['nb'])?'0':$calcproducts['nb']; + $valtoshow=price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow)?'0':$valtoshow; print ""; print ''; @@ -698,7 +699,9 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print ''."\n"; + print '
'; + print '
'."\n"; + print ""; if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'],$_SERVER["PHP_SELF"],'m.rowid','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'],$_SERVER["PHP_SELF"],'m.datem','',$param,'',$sortfield,$sortorder); @@ -740,7 +743,7 @@ if ($resql) { // Ref print ''; } if (! empty($arrayfields['m.datem']['checked'])) @@ -1000,12 +1003,16 @@ if ($resql) } $db->free($resql); - print "
'; - print ''; + print ''; print '

"; + print ""; + print ''; + print ""; // Add number of product when there is a filter on period if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) { - $productidselected=0; + print "
"; + + $productidselected=0; foreach ($arrayofuniqueproduct as $key => $val) { $productidselected=$key; @@ -1031,8 +1038,6 @@ if ($resql) print "
\n"; //print ''; } - - } else { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 4482e249410..7a0068fdda8 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -55,8 +55,8 @@ $stocklimit = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel'); $fieldid = isset($_GET["ref"])?'ref':'rowid'; -$d_eatby=dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); -$d_sellby=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); +$d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); +$d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $pdluoid=GETPOST('pdluoid','int'); // Security check @@ -453,8 +453,8 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) } else { - $d_eatby=dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); - $d_sellby=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); + $d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $pdluo->batch=GETPOST("batch_number",'san_alpha'); $pdluo->eatby=$d_eatby; $pdluo->sellby=$d_sellby; @@ -785,8 +785,10 @@ if (empty($reshook)) * Stock detail (by warehouse). May go down into batch details. */ +print '
'; print ''; -print ''; +print ''; +print ''; print ''; print ''; print ''; @@ -918,10 +920,11 @@ else print $langs->trans("Variable"); print ''; print ""; print "
'.$langs->trans("Warehouse").'
'.$langs->trans("Warehouse").''.$langs->trans("NumberOfUnit").''.$langs->trans("AverageUnitPricePMPShort").''.$langs->trans("EstimatedStockValueShort").'
"; +print '
'; if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { - print '

'; + print '

'; print_titre($langs->trans('AddNewProductStockWarehouse')); //print '
'; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 1843506bd79..848bc519946 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -142,7 +142,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_entity=''; $search_product=''; @@ -227,7 +227,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."product_lot as t"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot_extrafields as ef on (t.rowid = ef.fk_object)"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.rowid = t.fk_product"; -//$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")"; +//$sql.= " WHERE u.entity IN (".getEntity('productlot',1).")"; if ($search_entity) $sql.= natural_search("entity",$search_entity); if ($search_product) $sql.= natural_search("p.ref",$search_product); @@ -259,7 +259,7 @@ $sql.=$db->order($sortfield,$sortorder); //$sql.= $db->plimit($conf->liste_limit+1, $offset); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -339,7 +339,8 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print ''."\n"; + print '
'; + print '
'."\n"; // Fields title print ''; @@ -587,7 +588,8 @@ if ($resql) print $hookmanager->resPrint; print '
'."\n"; - + print ''; + print ''."\n"; /* diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index a9b2dc57b1b..5281d913d95 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -120,7 +120,7 @@ if ($action == 'order' && isset($_POST['valid'])) $qty = GETPOST('tobuy'.$i, 'int'); //$desc = GETPOST('desc'.$i, 'alpha'); $sql = 'SELECT fk_product, fk_soc, ref_fourn'; - $sql .= ', tva_tx, unitprice FROM '; + $sql .= ', tva_tx, unitprice, remise_percent FROM '; $sql .= MAIN_DB_PREFIX . 'product_fournisseur_price'; $sql .= ' WHERE rowid = ' . $supplierpriceid; $resql = $db->query($sql); @@ -152,6 +152,7 @@ if ($action == 'order' && isset($_POST['valid'])) $tva = $line->tva_tx / 100; $line->total_tva = $line->total_ht * $tva; $line->total_ttc = $line->total_ht + $line->total_tva; + $line->remise_percent = $obj->remise_percent; $line->ref_fourn = $obj->ref_fourn; $suppliers[$obj->fk_soc]['lines'][] = $line; } @@ -334,7 +335,7 @@ if ($usevirtualstock) $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; $sqlCommandesCli.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sqlCommandesCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlCommandesCli.= " WHERE c.entity IN (".getEntity('order', 1).")"; + $sqlCommandesCli.= " WHERE c.entity IN (".getEntity('commande', 1).")"; $sqlCommandesCli.= " AND cd.fk_product = p.rowid"; $sqlCommandesCli.= " AND c.fk_statut IN (1,2))"; diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index b609e96661a..1f6ae678a81 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -213,13 +213,13 @@ if ($action == 'edit') print ''; print ''; print ''; if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; @@ -313,14 +313,14 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print ''; print ''; // Other field (not used) if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 012a71f21a0..d803b55c875 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -347,8 +347,9 @@ else { print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'
'; } -print '
'; -print "\n"; + +dol_fiche_end(); + // Filter on user /* dol_fiche_head(''); @@ -382,18 +383,20 @@ print "\n"; print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. -print '
'; +print '
'; print $langs->trans("AssignTaskToMe").'
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0); -print ''; +print ''; //print ''; print '
'; print '
'; -print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; - $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); + $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); print '
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'; - $doleditor = new DolEditor("other-$key", $object->multilangs[$key]["other"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); + $doleditor = new DolEditor("other-$key", $object->multilangs[$key]["other"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); } print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; - $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); + $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); print '
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").''; - $doleditor = new DolEditor('other', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); + $doleditor = new DolEditor('other', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); print '
'; +print '
'; +print '
'."\n"; + print ''; print ''; print ''; @@ -444,8 +447,7 @@ else print ''; } print "
'.$langs->trans("RefTask").''.$langs->trans("LabelTask").'
'.$langs->trans("NoTasks").'
"; - -dol_fiche_end(); +print ''; print '
'; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 396eb352d3b..c64105bca62 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -342,8 +342,8 @@ else { print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'
'; } -print '
'; -print "\n"; + +dol_fiche_end(); // Filter on user /* dol_fiche_head(''); @@ -377,18 +377,19 @@ print "\n"; print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. -print '
'; +print '
'; print $langs->trans("AssignTaskToMe").'
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0); -print ''; +print ''; //print ''; print '
'; print '
'; -print ''; +print '
'; +print '
'."\n"; print ''; print ''; @@ -465,12 +466,11 @@ else print ''; } print "
'.$langs->trans("RefTask").'
'.$langs->trans("NoTasks").'
"; +print '
'; print ''."\n"; print ''."\n"; -dol_fiche_end(); - print '
'; print ''; print '
'; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 5e639f6c920..9aae20a6300 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -615,12 +615,12 @@ if ($action == 'create' && $user->rights->projet->creer) }); '; } -else +elseif ($object->id > 0) { /* * Show or edit */ - + $res=$object->fetch_optionals($object->id,$extralabels); // To verify role of users @@ -1127,6 +1127,10 @@ else $parameters=array(); $reshook=$hookmanager->executeHooks('mainCardTabAddMore',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } +else +{ + print $langs->trans("RecordNotFound"); +} llxFooter(); diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 74650407f87..f36df0773eb 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -19,6 +19,7 @@ use Luracast\Restler\RestException; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; /** * API class for projects @@ -50,6 +51,7 @@ class Projects extends DolibarrApi global $db, $conf; $this->db = $db; $this->project = new Project($this->db); + $this->task = new Task($this->db); } /** @@ -154,7 +156,7 @@ class Projects extends DolibarrApi $obj = $db->fetch_object($result); $project_static = new Project($db); if($project_static->fetch($obj->rowid)) { - $obj_ret[] = parent::_cleanObjectDatas($project_static); + $obj_ret[] = $this->_cleanObjectDatas($project_static); } $i++; } @@ -203,13 +205,13 @@ class Projects extends DolibarrApi /** * Get tasks of a project * - * @param int $id Id of project + * @param int $id Id of project + * @param int $includetimespent 0=Return only list of tasks. 1=Include a summary of time spent, 2=Include details of time spent lines (2 is no implemented yet) + * @return int * * @url GET {id}/tasks - * - * @return int */ - function getLines($id) { + function getLines($id, $includetimespent=0) { if(! DolibarrApiAccess::$user->rights->projet->lire) { throw new RestException(401); } @@ -224,23 +226,36 @@ class Projects extends DolibarrApi } $this->project->getLinesArray(DolibarrApiAccess::$user); $result = array(); - foreach ($this->project->lines as $line) { - array_push($result,$this->_cleanObjectDatas($line)); + foreach ($this->project->lines as $line) // $line is a task + { + if ($includetimespent == 1) + { + $timespent = $line->getSummaryOfTimeSpent(0); + } + if ($includetimespent == 1) + { + // TODO + // Add class for timespent records and loop and fill $line->lines with records of timespent + } + array_push($result,$this->_cleanObjectDatas($line)); } return $result; } /** - * Get users and roles assigned to a project + * Get roles a user is assigned to a project with * - * @param int $id Id of project + * @param int $id Id of project + * @param int $userid Id of user (0 = connected user) * * @url GET {id}/roles * * @return int */ - function getRoles($id) { + function getRoles($id, $userid=0) { + global $db; + if(! DolibarrApiAccess::$user->rights->projet->lire) { throw new RestException(401); } @@ -256,7 +271,13 @@ class Projects extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $taskstatic=new Task($this->db); - $this->project->roles = $taskstatic->getUserRolesForProjectsOrTasks(DolibarrApiAccess::$user, 0, $id, 0); + $userp = DolibarrApiAccess::$user; + if ($userid > 0) + { + $userp = new User($this->db); + $userp->fetch($userid); + } + $this->project->roles = $taskstatic->getUserRolesForProjectsOrTasks($userp, 0, $id, 0); $result = array(); foreach ($this->project->roles as $line) { array_push($result,$this->_cleanObjectDatas($line)); @@ -330,10 +351,10 @@ class Projects extends DolibarrApi * Update a task to given project * * @param int $id Id of project to update - * @param int $lineid Id of line to update + * @param int $taskid Id of task to update * @param array $request_data Projectline data * - * @url PUT {id}/tasks/{lineid} + * @url PUT {id}/tasks/{taskid} * * @return object */ @@ -385,52 +406,6 @@ class Projects extends DolibarrApi }*/ - /** - * Delete a tasks of given project - * - * - * @param int $id Id of project to update - * @param int $taskid Id of task to delete - * - * @url DELETE {id}/tasks/{taskid} - * - * @return int - */ - function delLine($id, $taskid) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { - throw new RestException(401); - } - - $result = $this->project->fetch($id); - if( ! ($result > 0) ) { - throw new RestException(404, 'Project not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $taskstatic=new Task($this->db); - $result = $taskstatic->fetch($taskid); - if( ! ($result > 0) ) { - throw new RestException(404, 'Task not found'); - } - - $deleteRes = $taskstatic->delete(DolibarrApiAccess::$user); - - if( ! ($deleteRes > 0)) { - throw new RestException(500, 'Error when delete tasks : '.$taskstatic->error); - } - - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Task deleted' - ) - ); - } - /** * Update project general fields (won't touch lines of project) @@ -446,7 +421,7 @@ class Projects extends DolibarrApi } $result = $this->project->fetch($id); - if( ! $result ) { + if ($result <= 0) { throw new RestException(404, 'Project not found'); } @@ -454,13 +429,18 @@ class Projects extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach($request_data as $field => $value) { + if ($field == 'id') continue; $this->project->$field = $value; } - if($this->project->update(DolibarrApiAccess::$user, 0)) + if($this->project->update(DolibarrApiAccess::$user, 0) > 0) + { return $this->get($id); - - return false; + } + else + { + throw new RestException(500, $this->project->error); + } } /** @@ -498,8 +478,10 @@ class Projects extends DolibarrApi } /** - * Validate a project - * + * Validate a project. + * You can test this API with the following input message + * { "notrigger": 0 } + * * @param int $id Project ID * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @@ -543,6 +525,56 @@ class Projects extends DolibarrApi ); } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + * + * @todo use an array for properties to clean + * + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->note); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->mode_reglement_id); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + + unset($object->weekWorkLoad); + unset($object->weekWorkLoad); + + //unset($object->lines); // for task we use timespent_lines, but for project we use lines + + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + + return $object; + } + /** * Validate fields before create or update object * diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php new file mode 100644 index 00000000000..a5bab614a4a --- /dev/null +++ b/htdocs/projet/class/api_tasks.class.php @@ -0,0 +1,613 @@ + + * Copyright (C) 2016 Laurent Destailleur + * + * 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 . + */ + + use Luracast\Restler\RestException; + + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + +/** + * API class for projects + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class Tasks extends DolibarrApi +{ + + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'ref', + 'label' + ); + + /** + * @var Task $task {@type Task} + */ + public $task; + + /** + * Constructor + */ + function __construct() + { + global $db, $conf; + $this->db = $db; + $this->task = new Task($this->db); + } + + /** + * Get properties of a task object + * + * Return an array with task informations + * + * @param int $id ID of task + * @param int $includetimespent 0=Return only task. 1=Include a summary of time spent, 2=Include details of time spent lines (2 is no implemented yet) + * @return array|mixed data without useless information + * + * @throws RestException + */ + function get($id, $includetimespent=0) + { + if(! DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } + + $result = $this->task->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Task not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('task',$this->task->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if ($includetimespent == 1) + { + $timespent = $this->task->getSummaryOfTimeSpent(0); + } + if ($includetimespent == 1) + { + // TODO + // Add class for timespent records and loop and fill $line->lines with records of timespent + } + + return $this->_cleanObjectDatas($this->task); + } + + + + /** + * List tasks + * + * Get a list of tasks + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of project objects + */ + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { + global $db, $conf; + + $obj_ret = array(); + // case of external user, $thirdpartyid param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + + // If the internal user must only see his customers, force searching by him + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t"; + + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + + $sql.= ' WHERE t.entity IN ('.getEntity('project', 1).')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + dol_syslog("API Rest request"); + $result = $db->query($sql); + + if ($result) + { + $num = $db->num_rows($result); + while ($i < min($num, ($limit <= 0 ? $num : $limit))) + { + $obj = $db->fetch_object($result); + $task_static = new Task($db); + if($task_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($task_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve task list'); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No task found'); + } + return $obj_ret; + } + + /** + * Create task object + * + * @param array $request_data Request data + * @return int ID of project + */ + function post($request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401, "Insuffisant rights"); + } + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach($request_data as $field => $value) { + $this->task->$field = $value; + } + /*if (isset($request_data["lines"])) { + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->project->lines = $lines; + }*/ + if ($this->task->create(DolibarrApiAccess::$user) <= 0) { + $errormsg = $this->task->error; + throw new RestException(500, $errormsg ? $errormsg : "Error while creating task"); + } + + return $this->task->id; + } + + /** + * Get time spent of a task + * + * @param int $id Id of task + * @return int + * + * @url GET {id}/tasks + */ + /* + function getLines($id, $includetimespent=0) { + if(! DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } + + $result = $this->project->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Project not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->project->getLinesArray(DolibarrApiAccess::$user); + $result = array(); + foreach ($this->project->lines as $line) // $line is a task + { + if ($includetimespent == 1) + { + $timespent = $line->getSummaryOfTimeSpent(0); + } + if ($includetimespent == 1) + { + // TODO + // Add class for timespent records and loop and fill $line->lines with records of timespent + } + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } + */ + + /** + * Get roles a user is assigned to a task with + * + * @param int $id Id of task + * @param int $userid Id of user (0 = connected user) + * + * @url GET {id}/roles + * + * @return int + */ + function getRoles($id, $userid=0) { + global $db; + + if(! DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } + + $result = $this->task->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Task not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('task',$this->task->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $usert = DolibarrApiAccess::$user; + if ($userid > 0) + { + $usert = new User($this->db); + $usert->fetch($userid); + } + $this->task->roles = $this->task->getUserRolesForProjectsOrTasks(0, $usert, 0, $id); + $result = array(); + foreach ($this->task->roles as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } + + + /** + * Add a task to given project + * + * @param int $id Id of project to update + * @param array $request_data Projectline data + * + * @url POST {id}/tasks + * + * @return int + */ + /* + function postLine($id, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401); + } + + $result = $this->project->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Project not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->project->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $fk_parent_line, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->fk_unit, + $this->element, + $request_data->id + ); + + if ($updateRes > 0) { + return $this->get($id)->line->rowid; + + } + return false; + } + */ + + /** + * Update a task to given project + * + * @param int $id Id of project to update + * @param int $taskid Id of task to update + * @param array $request_data Projectline data + * + * @url PUT {id}/tasks/{taskid} + * + * @return object + */ + /* + function putLine($id, $lineid, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401); + } + + $result = $this->project->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Project not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->project->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->fk_unit + ); + + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; + }*/ + + + /** + * Update task general fields (won't touch time spent of task) + * + * @param int $id Id of task to update + * @param array $request_data Datas + * + * @return int + */ + function put($id, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401); + } + + $result = $this->task->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Task not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('task',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + foreach($request_data as $field => $value) { + if ($field == 'id') continue; + $this->task->$field = $value; + } + + if($this->task->update(DolibarrApiAccess::$user, 0) > 0) + { + return $this->get($id); + } + else + { + throw new RestException(500, $this->task->error); + } + } + + /** + * Delete task + * + * @param int $id Task ID + * + * @return array + */ + function delete($id) + { + if(! DolibarrApiAccess::$user->rights->projet->supprimer) { + throw new RestException(401); + } + $result = $this->task->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Task not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('task',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if( ! $this->task->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when delete task : '.$this->task->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Task deleted' + ) + ); + + } + + + /** + * Add time spent to a task of a project. + * You can test this API with the following input message + * { "date": "2016-12-31 23:15:00", "duration": 1800, "user_id": 1, "note": "My time test" } + * + * @param int $id Task ID + * @param datetime $date Date (YYYY-MM-DD HH:MI:SS in GMT) + * @param int $duration Duration in seconds (3600 = 1h) + * @param int $user_id User (Use 0 for connected user) + * @param string $note Note + * + * @url POST {id}/addtimespent + * + * @return array + */ + function addTimeSpent($id, $date, $duration, $user_id=0, $note='') + { + if(! DolibarrApiAccess::$user->rights->projet->creer) { + throw new RestException(401); + } + $result = $this->task->fetch($id); + if ($result <= 0) { + throw new RestException(404, 'Task not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $uid = $user_id; + if (empty($uid)) $uid = DolibarrApiAccess::$user->id; + + $newdate = dol_stringtotime($date, 1); + $this->task->timespent_date = $newdate; + $this->task->timespent_datehour = $newdate; + $this->task->timespent_withhour = 1; + $this->task->timespent_duration = $duration; + $this->task->timespent_fk_user = $user_id; + $this->task->timespent_note = $note; + + $result = $this->task->addTimeSpent(DolibarrApiAccess::$user, 0); + if ($result == 0) { + throw new RestException(500, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when adding time: '.$this->task->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Time spent added' + ) + ); + } + + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + * + * @todo use an array for properties to clean + * + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->note); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->mode_reglement_id); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + + unset($object->weekWorkLoad); + unset($object->weekWorkLoad); + + //unset($object->lines); // for task we use timespent_lines, but for project we use lines + + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + function _validate($data) + { + $object = array(); + foreach (self::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $object[$field] = $data[$field]; + + } + return $object; + } + + + // TODO + // getSummaryOfTimeSpent +} diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index cdddccbf432..7a88fc3112c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -97,6 +97,11 @@ class Project extends CommonObject */ public $date_m; + /** + * @var Task[] + */ + public $lines; + /** * Constructor @@ -228,7 +233,7 @@ class Project extends CommonObject * * @param User $user User object of making update * @param int $notrigger 1=Disable all triggers - * @return int + * @return int <=0 if KO, >0 if OK */ function update($user, $notrigger=0) { @@ -346,7 +351,7 @@ class Project extends CommonObject } /** - * Get object and lines from database + * Get object from database * * @param int $id Id of object to load * @param string $ref Ref of project diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 2baccfb3382..27099ef4d91 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -33,7 +33,9 @@ class Task extends CommonObject { public $element='project_task'; //!< Id that identify managed objects public $table_element='projet_task'; //!< Name of table without prefix where object is stored + public $fk_element='fk_task'; public $picto = 'task'; + protected $childtables=array('projet_task_time'); // To test if we can delete object var $fk_task_parent; var $label; @@ -50,6 +52,15 @@ class Task extends CommonObject var $fk_user_valid; var $rang; + var $timespent_min_date; + var $timespent_max_date; + var $timespent_total_duration; + var $timespent_total_amount; + var $timespent_nblinesnull; + var $timespent_nblines; + // For detail of lines of timespent record, there is the property ->lines in common + + // Var used to call method addTimeSpent(). Bad practice. var $timespent_id; var $timespent_duration; var $timespent_old_duration; @@ -259,7 +270,7 @@ class Task extends CommonObject * * @param User $user User that modify * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK + * @return int <=0 if KO, >0 if OK */ function update($user=null, $notrigger=0) { @@ -383,13 +394,22 @@ class Task extends CommonObject $this->db->begin(); if ($this->hasChildren() > 0) + { + dol_syslog(get_class($this)."::delete Can't delete record as it has some sub tasks", LOG_WARNING); + $this->error='ErrorRecordHasSubTasks'; + $this->db->rollback(); + return 0; + } + + $objectisused = $this->isObjectUsed($this->id); + if (! empty($objectisused)) { dol_syslog(get_class($this)."::delete Can't delete record as it has some child", LOG_WARNING); $this->error='ErrorRecordHasChildren'; $this->db->rollback(); return 0; } - + if (! $error) { // Delete linked contacts @@ -584,7 +604,7 @@ class Task extends CommonObject $this->fk_projet=''; $this->ref='TK01'; $this->fk_task_parent=''; - $this->title='Specimen task TK01'; + $this->label='Specimen task TK01'; $this->duration_effective=''; $this->fk_user_creat=''; $this->progress='25'; @@ -757,10 +777,10 @@ class Task extends CommonObject * Return list of roles for a user for each projects or each tasks (or a particular project or a particular task). * * @param User $userp Return roles on project for this internal user. If set, usert and taskid must not be defined. - * @param User $usert Return roles on task for this internal user. If set userp must not be defined. -1 means no filter. + * @param User $usert Return roles on task for this internal user. If set userp must NOT be defined. -1 means no filter. * @param int $projectid Project id list separated with , to filter on project * @param int $taskid Task id to filter on a task - * @param string $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. + * @param integer $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. * @return array Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') */ function getUserRolesForProjectsOrTasks($userp, $usert, $projectid='', $taskid=0, $filteronprojstatus=-1) @@ -784,7 +804,8 @@ class Task extends CommonObject /* Liste des taches et role sur les projets ou taches */ $sql = "SELECT pt.rowid as pid, ec.element_id, ctc.code, ctc.source"; if ($userp) $sql.= " FROM ".MAIN_DB_PREFIX."projet as pt"; - if ($usert) $sql.= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as pt"; + if ($usert && $filteronprojstatus > -1) $sql.= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as pt"; + if ($usert && $filteronprojstatus <= -1) $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sql.= " WHERE pt.rowid = ec.element_id"; @@ -809,7 +830,7 @@ class Task extends CommonObject } //print $sql; - dol_syslog(get_class($this)."::getUserRolesForProjectsOrTasks", LOG_DEBUG); + dol_syslog(get_class($this)."::getUserRolesForProjectsOrTasks execute request", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -861,7 +882,7 @@ class Task extends CommonObject * * @param User $user User object * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return void + * @return int <=0 if KO, >0 if OK */ function addTimeSpent($user, $notrigger=0) { @@ -923,7 +944,7 @@ class Task extends CommonObject $ret = -1; } - if ($ret >= 0) + if ($ret > 0) { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; @@ -950,7 +971,7 @@ class Task extends CommonObject } } - if ($ret >=0) + if ($ret >0) { $this->db->commit(); } @@ -965,7 +986,7 @@ class Task extends CommonObject * Calculate total of time spent for task * * @param int $userid Filter on user id. 0=No filter - * @return array Array of info for task array('min_date', 'max_date', 'total_duration') + * @return array Array of info for task array('min_date', 'max_date', 'total_duration', 'total_amount', 'nblines', 'nblinesnull') */ function getSummaryOfTimeSpent($userid=0) { @@ -983,7 +1004,10 @@ class Task extends CommonObject $sql = "SELECT"; $sql.= " MIN(t.task_datehour) as min_date,"; $sql.= " MAX(t.task_datehour) as max_date,"; - $sql.= " SUM(t.task_duration) as total_duration"; + $sql.= " SUM(t.task_duration) as total_duration,"; + $sql.= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as total_amount,"; + $sql.= " COUNT(t.rowid) as nblines,"; + $sql.= " SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql.= " WHERE t.fk_task = ".$id; if ($userid > 0) $sql.=" AND t.fk_user = ".$userid; @@ -994,22 +1018,28 @@ class Task extends CommonObject { $obj = $this->db->fetch_object($resql); - $result['min_date'] = $obj->min_date; - $result['max_date'] = $obj->max_date; - $result['total_duration'] = $obj->total_duration; - + $result['min_date'] = $obj->min_date; // deprecated. use the ->timespent_xxx instead + $result['max_date'] = $obj->max_date; // deprecated. use the ->timespent_xxx instead + $result['total_duration'] = $obj->total_duration; // deprecated. use the ->timespent_xxx instead + + $this->timespent_min_date=$this->db->jdate($obj->min_date); + $this->timespent_max_date=$this->db->jdate($obj->max_date); + $this->timespent_total_duration=$obj->total_duration; + $this->timespent_total_amount=$obj->total_amount; + $this->timespent_nblinesnull=($obj->nblinesnull?$obj->nblinesnull:0); + $this->timespent_nblines=($obj->nblines?$obj->nblines:0); + $this->db->free($resql); - return $result; } else { dol_print_error($this->db); - return $result; } + return $result; } /** - * Calculate vamue of time consumed using the thm (hourly amount value of work for user entering time) + * Calculate value of time consumed using the thm (hourly amount value of work for user entering time) * * @param User $fuser Filter on a dedicated user * @param string $dates Start date (ex 00:00:00) @@ -1064,7 +1094,7 @@ class Task extends CommonObject } /** - * Load object in memory from database + * Load one record of time spent * * @param int $id Id object * @return int <0 if KO, >0 if OK diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 958f0b242a2..6d1e9cb2828 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -390,7 +390,7 @@ $listofreferent=array( 'table'=>'projet_task', 'datefieldname'=>'task_date', 'disableamount'=>0, - 'test'=>$conf->projet->enabled && $user->rights->projet->lire && $conf->salaries->enabled && empty($conf->global->PROJECT_HIDE_TASKS)), + 'test'=>$conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS)), ); $parameters=array('listofreferent'=>$listofreferent); @@ -880,13 +880,21 @@ foreach ($listofreferent as $key => $value) if ($tablename == 'don') $total_ht_by_line=$element->amount; elseif ($tablename == 'projet_task') { - $tmp = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty - $total_ht_by_line = price2num($tmp['amount'],'MT'); - if ($tmp['nblinesnull'] > 0) - { - $langs->load("errors"); - $warning=$langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency); - } + if (! empty($conf->salaries->enabled)) + { + // TODO Permission to read daily rate + $tmp = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty + $total_ht_by_line = price2num($tmp['amount'],'MT'); + if ($tmp['nblinesnull'] > 0) + { + $langs->load("errors"); + $warning=$langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency); + } + } + else + { + print $langs->trans("ModuleDisabled"); + } } else { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 8c2c8909a84..b98126a6bd0 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -315,7 +315,7 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // No $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -450,7 +450,8 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -print ''; +print '
'; +print '
'."\n"; print ''; if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); @@ -867,6 +868,7 @@ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // N print $hookmanager->resPrint; print "
\n"; +print '
'; print "\n"; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 986c0537bc5..8a98b99221b 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -339,7 +339,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third { require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; - $defaultref = $modTask->getNextValue($soc,$object); + $defaultref = $modTask->getNextValue($object->thirdparty,null); } if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; @@ -351,7 +351,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; print ''.$langs->trans("Label").''; - print ''; + print ''; print ''; // List of projects diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 1179ca7546e..86d79676d58 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -308,7 +308,7 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // No $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -424,7 +424,8 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -print ''; +print '
'; +print '
'."\n"; print ''; if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder); @@ -826,6 +827,7 @@ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // N print $hookmanager->resPrint; print "
"; +print ''; print ''; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 276fc1cd722..5a9a6704566 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -704,6 +704,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + print '
'; print ''."\n"; print ''; @@ -975,6 +976,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print "
"; + print '
'; print ""; } } diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index f21b2d2409c..4bad572ed8b 100644 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -51,6 +51,13 @@ $langs->load("companies"); $langs->load("paybox"); $langs->load("paypal"); +$PAYPALTOKEN=GETPOST('TOKEN'); +if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); +$PAYPALPAYERID=GETPOST('PAYERID'); +if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); +$PAYPALFULLTAG=GETPOST('FULLTAG'); +if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + /* * Actions @@ -73,6 +80,18 @@ dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal'); // Send an email if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) { + // Get on url call + $token = $PAYPALTOKEN; + $fulltag = $PAYPALFULLTAG; + $payerID = $PAYPALPAYERID; + // Set by newpayment.php + $paymentType = $_SESSION['PaymentType']; + $currencyCodeType = $_SESSION['currencyCodeType']; + $FinalPaymentAmt = $_SESSION["Payment_Amount"]; + // From env + $ipaddress = $_SESSION['ipaddress']; + + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; @@ -102,11 +121,6 @@ print ''."\n"; print '
'."\n"; print $langs->trans("YourPaymentHasNotBeenRecorded")."

"; -$PAYPALTOKEN=GETPOST('TOKEN'); -if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); -$PAYPALFULLTAG=GETPOST('FULLTAG'); -if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); - if (! empty($conf->global->PAYPAL_MESSAGE_KO)) print $conf->global->PAYPAL_MESSAGE_KO; print "\n
\n"; diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 5eaa20003af..175352f404b 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -242,8 +242,8 @@ if (! empty($moreforfilter))
- -


Example 2 : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables
+ -


Example 3 : Table using tags: div.tagtable+div.tagtr+div or div.tagtable+div.tagtr+div.tagtd => Use this for tables that need to have a different form for each line, but AVOID IT if possible (drag and drop of lines does not work for this case, also height of title can't be forced to a minimum)

+


Example 2 : Table using tags: div.tagtable+(div|form).tagtr+div[.tagtd] => Use this for tables that need to have a different form for each line, but AVOID IT if possible (drag and drop of lines does not work for this case, also height of title can't be forced to a minimum)

use_javascript_ajax)) include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; ?> -
+
Title A
title B
diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 3b6338f0fce..b2ef82cf8c1 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -186,7 +186,11 @@ print ''; print ''; print ''; -print ''."\n"; +$moreforfilter = ''; + +print '
'; +print '
'."\n"; + print ''; if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['ty.label']['checked'])) print_liste_field_titre($arrayfields['ty.label']['label'],$_SERVER["PHP_SELF"],"t.code","",$param,"",$sortfield,$sortorder); @@ -250,62 +254,62 @@ print "\n"; if ($ret) { - foreach ($object->lines as $resource) - { - $var=!$var; + foreach ($object->lines as $resource) + { + $var=!$var; - $style=''; - if ($resource->id == GETPOST('lineid')) $style='style="background: orange;"'; + $style=''; + if ($resource->id == GETPOST('lineid')) $style='style="background: orange;"'; - print ''; + print ''; - if (! empty($arrayfields['t.ref']['checked'])) - { - print ''; - } + if (! empty($arrayfields['t.ref']['checked'])) + { + print ''; + } - if (! empty($arrayfields['ty.label']['checked'])) - { - print ''; - } - // 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 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $resource->array_options[$tmpkey], '', 1); - print ''; - } - } - if (! $i) $totalarray['nbfield']++; - } + if (! empty($arrayfields['ty.label']['checked'])) + { + print ''; + } + // 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 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $resource->array_options[$tmpkey], '', 1); + print ''; + } + } + if (! $i) $totalarray['nbfield']++; + } - print ''; + print ''; - print ''; - } + print ''; + } - print '
'; - print $resource->getNomUrl(5); - print ''; + print $resource->getNomUrl(5); + print ''; - print $resource->type_label; - print ''; + print $resource->type_label; + print ''; - print ''; - print img_edit(); - print ''; - print ' '; - print ''; - print img_delete(); - print ''; - print ''; + print ''; + print img_edit(); + print ''; + print ' '; + print ''; + print img_delete(); + print ''; + print '
'; - print "\n"; + print ''; + print "\n"; } else { diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 96ac9f0154b..d2a244f9444 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -54,7 +54,7 @@ dol_syslog(join(',',$_GET)); if (! empty($action) && $action == 'fetch' && ! empty($id)) { - require DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $outjson=array(); diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 11cd1fee919..775d9d48cf4 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -115,7 +115,7 @@ class Contacts extends DolibarrApi $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid"; - $sql.= ' WHERE t.entity IN (' . getEntity('contact', 1) . ')'; + $sql.= ' WHERE t.entity IN (' . getEntity('socpeople', 1) . ')'; if ($socid) $sql.= " AND t.fk_soc = " . $socid; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) @@ -222,7 +222,8 @@ class Contacts extends DolibarrApi foreach ($request_data as $field => $value) { - $this->contact->$field = $value; + if ($field == 'id') continue; + $this->contact->$field = $value; } if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) diff --git a/htdocs/societe/class/api_deprecated_contact.class.php b/htdocs/societe/class/api_deprecated_contact.class.php index 56ef1eec19a..d3d085e7135 100644 --- a/htdocs/societe/class/api_deprecated_contact.class.php +++ b/htdocs/societe/class/api_deprecated_contact.class.php @@ -126,7 +126,7 @@ class ContactApi extends DolibarrApi $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON c.fk_soc = s.rowid"; - $sql.= ' WHERE c.entity IN (' . getEntity('contact', 1) . ')'; + $sql.= ' WHERE c.entity IN (' . getEntity('socpeople', 1) . ')'; if ($socid) $sql.= " AND c.fk_soc = " . $socid; @@ -143,7 +143,7 @@ class ContactApi extends DolibarrApi $sql .= " AND sc.fk_user = " . $search_sale; } - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -239,7 +239,8 @@ class ContactApi extends DolibarrApi foreach ($request_data as $field => $value) { - $this->contact->$field = $value; + if ($field == 'id') continue; + $this->contact->$field = $value; } if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) diff --git a/htdocs/societe/class/api_deprecated_thirdparty.class.php b/htdocs/societe/class/api_deprecated_thirdparty.class.php index 3179cb697ce..3e937557941 100644 --- a/htdocs/societe/class/api_deprecated_thirdparty.class.php +++ b/htdocs/societe/class/api_deprecated_thirdparty.class.php @@ -189,7 +189,7 @@ class ThirdpartyApi extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -328,6 +328,7 @@ class ThirdpartyApi extends DolibarrApi } foreach($request_data as $field => $value) { + if ($field == 'id') continue; $this->company->$field = $value; } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index de21e4fbbe0..13f28aea705 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -216,6 +216,7 @@ class Thirdparties extends DolibarrApi } foreach($request_data as $field => $value) { + if ($field == 'id') continue; $this->company->$field = $value; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 6acae492c33..cbc4a9670a1 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Marcos García * Copyright (C) 2013-2015 Raphaël Doursenaud @@ -57,6 +57,9 @@ $search_account_supplier_code=trim(GETPOST('search_account_supplier_code')); $search_town=trim(GETPOST("search_town")); $search_zip=trim(GETPOST("search_zip")); $search_state=trim(GETPOST("search_state")); +$search_email=trim(GETPOST('search_email')); +$search_phone=trim(GETPOST('search_phone')); +$search_url=trim(GETPOST('search_url')); $search_idprof1=trim(GETPOST('search_idprof1')); $search_idprof2=trim(GETPOST('search_idprof2')); $search_idprof3=trim(GETPOST('search_idprof3')); @@ -153,6 +156,9 @@ $arrayfields=array( 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), 'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0), 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), + 's.email'=>array('label'=>$langs->trans("Email"), 'checked'=>0), + 's.url'=>array('label'=>$langs->trans("Url"), 'checked'=>0), + 's.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>1), 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), 's.siren'=>array('label'=>$langs->trans("ProfId1Short"), 'checked'=>$checkedprofid1), 's.siret'=>array('label'=>$langs->trans("ProfId2Short"), 'checked'=>$checkedprofid2), @@ -208,6 +214,9 @@ if (empty($reshook)) $search_zip=""; $search_state=""; $search_country=''; + $search_email=''; + $search_phone=''; + $search_url=''; $search_idprof1=''; $search_idprof2=''; $search_idprof3=''; @@ -345,7 +354,7 @@ else dol_print_error($db); $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, "; $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; -$sql.= " s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.fk_pays,"; +$sql.= " s.email, s.phone, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; $sql.= " s.code_compta,s.code_compta_fournisseur,"; $sql.= " typent.code as typent_code,"; @@ -389,7 +398,10 @@ if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fourniss if ($search_town) $sql.= natural_search("s.town",$search_town); if ($search_zip) $sql.= natural_search("s.zip",$search_zip); if ($search_state) $sql.= natural_search("state.nom",$search_state); -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_email) $sql.= natural_search("s.email",$search_email); +if ($search_phone) $sql.= natural_search("s.phone",$search_phone); +if ($search_url) $sql.= natural_search("s.url",$search_url); if ($search_idprof1) $sql.= natural_search("s.siren",$search_idprof1); if ($search_idprof2) $sql.= natural_search("s.siret",$search_idprof2); if ($search_idprof3) $sql.= natural_search("s.ape",$search_idprof3); @@ -426,7 +438,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -576,29 +588,33 @@ $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfiel if (empty($arrayfields['customerorsupplier']['checked'])) print ''; -print ''; +print '
'; +print '
'."\n"; print ''; -if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); -if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($langs->trans("Gencod"), $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); +if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); -if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer -if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); -if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer +if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -615,9 +631,9 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -700,6 +716,27 @@ if (! empty($arrayfields['typent.code']['checked'])) print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; } +if (! empty($arrayfields['s.email']['checked'])) +{ + // Email + print ''; +} +if (! empty($arrayfields['s.phone']['checked'])) +{ + // Phone + print ''; +} +if (! empty($arrayfields['s.url']['checked'])) +{ + // Url + print ''; +} if (! empty($arrayfields['s.siren']['checked'])) { // IdProf1 @@ -932,6 +969,18 @@ while ($i < min($num, $limit)) print $typenArray[$obj->typent_code]; print ''; } + if (! empty($arrayfields['s.email']['checked'])) + { + print "\n"; + } + if (! empty($arrayfields['s.phone']['checked'])) + { + print "\n"; + } + if (! empty($arrayfields['s.url']['checked'])) + { + print "\n"; + } if (! empty($arrayfields['s.siren']['checked'])) { print "\n"; @@ -1061,6 +1110,7 @@ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // N print $hookmanager->resPrint; print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '".$obj->email."".$obj->phone."".$obj->url."".$obj->idprof1."
"; +print "
"; print ''; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 9236fc35f6f..db2592f225c 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -379,7 +379,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { ); // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); } @@ -469,7 +469,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 0220f775d7b..cc0465a0b68 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -109,7 +109,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_merge' && $confirm == 'yes') + if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer) { $object->fetch($socid); @@ -1013,7 +1013,7 @@ else print ''; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 3ab1c159545..8717e64fe38 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1649,6 +1649,7 @@ if ($action == 'create') include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } + print '
'; print ''; // Add free products/services form @@ -1674,7 +1675,7 @@ if ($action == 'create') } print '
'; - + print '
'; print "\n"; dol_fiche_end(); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index a50e8509ba5..a8e38098775 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -55,7 +55,7 @@ $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','al $search_societe=GETPOST('search_societe','alpha'); $search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_author=GETPOST('search_author','alpha'); -$viewstatut=$db->escape(GETPOST('viewstatut')); +$search_status=GETPOST('viewstatut','alpha')?GETPOST('viewstatut','alpha'):GETPOST('search_status','int'); $object_statut=$db->escape(GETPOST('supplier_proposal_statut')); $sall=GETPOST("sall"); @@ -89,11 +89,22 @@ if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='p.date_livraison'; +if (! $sortfield) $sortfield='sp.date_livraison'; if (! $sortorder) $sortorder='DESC'; -if($object_statut != '') -$viewstatut=$object_statut; +if ($object_statut != '') $search_status=$object_statut; + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$contextpage='supplierproposallist'; + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('supplierproposallist')); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('supplier_proposal'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -137,7 +148,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPO $monthvalid=''; $year=''; $month=''; - $viewstatut=''; + $search_status=''; $object_statut=''; } @@ -196,13 +207,30 @@ $companystatic=new Societe($db); $now=dol_now(); -$sql = 'SELECT s.rowid as socid, s.nom as name, s.town, s.client, s.code_client,'; -$sql.= ' p.rowid, p.note_private, p.total_ht, p.ref, p.fk_statut, p.fk_user_author, p.date_valid, p.date_livraison as dp,'; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; -$sql.= ' u.login'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'supplier_proposal as p'; -if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON p.rowid=pd.fk_supplier_proposal'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; +$sql = 'SELECT'; +if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +$sql.= ' s.rowid as socid, s.nom as name, s.town, s.client, s.code_client,'; +$sql.= " typent.code as typent_code,"; +$sql.= " state.code_departement as state_code, state.nom as state_name,"; +$sql.= ' sp.rowid, sp.note_private, sp.total_ht, sp.ref, sp.fk_statut, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; +$sql.= " p.rowid as project_id, p.ref as project_ref,"; +$sql.= " u.firstname, u.lastname, u.photo, u.login"; +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql.= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp'; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."supplier_proposal_extrafields as ef on (sp.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal'; +if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid'; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet"; // 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) @@ -210,55 +238,54 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE p.fk_soc = s.rowid'; -$sql.= ' AND p.entity = '.$conf->entity; +$sql.= ' WHERE sp.fk_soc = s.rowid'; +$sql.= ' AND sp.entity IN ('.getEntity('supplier_proposal', 1).')'; if (! $user->rights->societe->client->voir && ! $socid) //restriction { $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } -if ($search_ref) $sql .= natural_search('p.ref', $search_ref); +if ($search_ref) $sql .= natural_search('sp.ref', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_author) $sql.= " AND u.login LIKE '%".$db->escape(trim($search_author))."%'"; -if ($search_montant_ht) $sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'"; +if ($search_author) $sql .= natural_search('u.login', $search_author); +if ($search_montant_ht) $sql.= " AND sp.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($socid) $sql.= ' AND s.rowid = '.$socid; -if ($viewstatut <> '') $sql.= ' AND p.fk_statut IN ('.$viewstatut.')'; +if ($search_status <> '') $sql.= ' AND sp.fk_statut IN ('.$search_status.')'; if ($month > 0) { if ($year > 0 && empty($day)) - $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; else if ($year > 0 && ! empty($day)) - $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; else - $sql.= " AND date_format(p.date_livraison, '%m') = '".$month."'"; + $sql.= " AND date_format(sp.date_livraison, '%m') = '".$month."'"; } else if ($year > 0) { - $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } if ($monthvalid > 0) { if ($yearvalid > 0 && empty($dayvalid)) - $sql.= " AND p.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,$monthvalid,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,$monthvalid,false))."'"; + $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,$monthvalid,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,$monthvalid,false))."'"; else if ($yearvalid > 0 && ! empty($dayvalid)) - $sql.= " AND p.date_valid BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $monthvalid, $dayvalid, $yearvalid))."' AND '".$db->idate(dol_mktime(23, 59, 59, $monthvalid, $dayvalid, $yearvalid))."'"; + $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $monthvalid, $dayvalid, $yearvalid))."' AND '".$db->idate(dol_mktime(23, 59, 59, $monthvalid, $dayvalid, $yearvalid))."'"; else - $sql.= " AND date_format(p.date_valid, '%m') = '".$monthvalid."'"; + $sql.= " AND date_format(sp.date_valid, '%m') = '".$monthvalid."'"; } else if ($yearvalid > 0) { - $sql.= " AND p.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,1,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,12,false))."'"; + $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,1,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,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 c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; + $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".$search_user; } +$sql.= ' ORDER BY '.$sortfield.' '.$sortorder.', sp.ref DESC'; -$sql.= ' ORDER BY '.$sortfield.' '.$sortorder.', p.ref DESC'; - -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -279,7 +306,7 @@ if ($result) $soc->fetch($socid); } - $param='&socid='.$socid.'&viewstatut='.$viewstatut; + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($sall) $param.='&sall='.$sall; @@ -291,7 +318,9 @@ if ($result) if ($search_sale > 0) $param.='&search_sale='.$search_sale; if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; if ($search_author) $param.='&search_author='.$search_author; - + if ($socid > 0) $param.='&socid='.$socid; + if ($search_status != '') $param.='&search_status='.$search_status; + // Lignes des champs de filtre print '
'; if ($optioncss != '') print ''; @@ -341,15 +370,16 @@ if ($result) } + print '
'; print ''; print ''; - print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'sp.ref','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Supplier'),$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'p.date_valid','',$param, 'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('SupplierProposalDate'),$_SERVER["PHP_SELF"],'p.date_livraison','',$param, 'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'sp.date_valid','',$param, 'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('SupplierProposalDate'),$_SERVER["PHP_SELF"],'sp.date_livraison','',$param, 'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'sp.total_ht','',$param, 'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Author'),$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'sp.fk_statut','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -388,7 +418,7 @@ if ($result) print ''; print ''; print ''; // Check boxes print '
'; - $formpropal->selectProposalStatus($viewstatut,1,0,1,'supplier'); + $formpropal->selectProposalStatus($search_status,1,0,1,'supplier','search_status'); print ''; @@ -514,7 +544,8 @@ if ($result) } print '
'; - + print '
'; + print '
'; $db->free($result); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ab9c2f2b7d6..6685b0cc745 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -582,15 +582,18 @@ div.myavailability { } /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ -.table-responsive { +/*.table-responsive { width: calc(100% - 330px); margin-bottom: 15px; overflow-y: hidden; -ms-overflow-style: -ms-autohiding-scrollbar; +}*/ +.div-table-responsive { + overflow-x: auto; + min-height: 0.01%; } - /* ============================================================================== */ /* Styles to hide objects */ /* ============================================================================== */ @@ -613,6 +616,7 @@ div.myavailability { .minwidth400imp { min-width: 400px !important; } .minwidth500imp { min-width: 500px !important; } } +.maxwidth25 { max-width: 25px; } .maxwidth50 { max-width: 50px; } .maxwidth75 { max-width: 75px; } .maxwidth100 { max-width: 100px; } @@ -627,6 +631,7 @@ div.myavailability { .titlefieldcreate { width: 20%; } .titlefield { width: 25%; } .titlefieldmiddle { width: 50%; } +.imgmaxwidth180 { max-width: 180px; } /* Force values for small screen 1400 */ @media only screen and (max-width: 1400px) @@ -986,6 +991,9 @@ img.photoref, div.photoref { width: 80px; object-fit: contain; } +img.fitcontain { + object-fit: contain; +} div.photoref { display:table-cell; vertical-align:middle; @@ -2397,7 +2405,6 @@ td.border, div.tagtable div div.border { border-bottom: 1px solid #000000; border-left: 1px solid #000000; } - .table-key-border-col { /* width: 25%; */ vertical-align:top; @@ -4511,7 +4518,7 @@ img.demothumb { } @media only screen and (max-width: 767px) { - .imgopensurveywizard { width:95%; height: auto; } + .imgopensurveywizard, .imgautosize { width:95%; height: auto; } #tooltip { position: absolute; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 6d8bc972ceb..43e5398b13e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -593,6 +593,10 @@ div.myavailability { overflow-y: hidden; -ms-overflow-style: -ms-autohiding-scrollbar; } +.div-table-responsive { + overflow-x: auto; + min-height: 0.01%; +} /* ============================================================================== */ @@ -617,6 +621,7 @@ div.myavailability { .minwidth400imp { min-width: 400px !important; } .minwidth500imp { min-width: 500px !important; } } +.maxwidth25 { max-width: 25px; } .maxwidth50 { max-width: 50px; } .maxwidth75 { max-width: 75px; } .maxwidth100 { max-width: 100px; } @@ -631,6 +636,8 @@ div.myavailability { .titlefieldcreate { width: 20%; } .titlefield { width: 25%; } .titlefieldmiddle { width: 50%; } +.imgmaxwidth180 { max-width: 180px; } + /* Force values for small screen 1400 */ @media only screen and (max-width: 1400px) @@ -1033,6 +1040,9 @@ img.photoref, div.photoref { width: 80px; object-fit: contain; } +img.fitcontain { + object-fit: contain; +} div.photoref { display:table-cell; vertical-align:middle; @@ -1046,6 +1056,7 @@ img.photorefnoborder { object-fit: contain; border: 1px solid #CCC; } + .underrefbanner { } .underbanner { @@ -4436,7 +4447,7 @@ img.demothumb { } @media only screen and (max-width: 767px) { - .imgopensurveywizard { width:95%; height: auto; } + .imgopensurveywizard, .imgautosize { width:95%; height: auto; } #tooltip { position: absolute; diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index ef7ffd9f70b..62efff2f88f 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2016 Laurent Destailleur * Copyright (C) 2011-2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -164,6 +164,7 @@ $selectedvalue=$conf->global->AGENDA_DISABLE_EXT; if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; $var=true; +print '
'; print ""; print ""; @@ -204,7 +205,7 @@ while ($i <= $MAXAGENDA) } print '
'; - +print '
'; dol_fiche_end(); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 0cd5b077996..8fa91cb57a2 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -760,7 +760,7 @@ if (($action == 'create') || ($action == 'adduserldap')) // Position/Job print ''.$langs->trans("PostOrFunction").''; print ''; - print ''; + print ''; print ''; // Gender @@ -785,7 +785,7 @@ if (($action == 'create') || ($action == 'adduserldap')) } else { - print ''; + print ''; } print ''; @@ -997,7 +997,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''.$langs->trans("Signature").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,90); + $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%'); print $doleditor->Create(1); print ''; @@ -1102,7 +1102,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print $langs->trans("Note"); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note','','',120,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_3,90); + $doleditor=new DolEditor('note','','',120,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_3,'90%'); $doleditor->Create(); print "\n"; @@ -2119,7 +2119,7 @@ else if ($caneditfield) { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,72); + $doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%'); print $doleditor->Create(1); } else diff --git a/htdocs/user/class/api_deprecated_user.class.php b/htdocs/user/class/api_deprecated_user.class.php index f080e8a3b45..278ce766878 100644 --- a/htdocs/user/class/api_deprecated_user.class.php +++ b/htdocs/user/class/api_deprecated_user.class.php @@ -191,7 +191,8 @@ class UserApi extends DolibarrApi foreach ($request_data as $field => $value) { - $this->useraccount->$field = $value; + if ($field == 'id') continue; + $this->useraccount->$field = $value; } if ($this->useraccount->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index e177b4d52ec..db18bea229a 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -214,7 +214,8 @@ class Users extends DolibarrApi foreach ($request_data as $field => $value) { - $this->useraccount->$field = $value; + if ($field == 'id') continue; + $this->useraccount->$field = $value; } if ($this->useraccount->update(DolibarrApiAccess::$user, 1)) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 541d847a45b..936673b1894 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -256,7 +256,7 @@ if ($action == 'create') print "".''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note','','',240,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_8,90); + $doleditor=new DolEditor('note','','',240,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_8,'90%'); $doleditor->Create(); print "\n"; @@ -531,7 +531,7 @@ else print ''.$langs->trans("Description").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note',$object->note,'',240,'dolibarr_notes','',true,false,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_8,90); + $doleditor=new DolEditor('note',$object->note,'',240,'dolibarr_notes','',true,false,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_8,'90%'); $doleditor->Create(); print ''; print "\n"; diff --git a/htdocs/user/index.php b/htdocs/user/index.php index f5d9407d2e3..b1aba55a73f 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -311,7 +311,10 @@ $moreforfilter=''; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -print ''; + +print '
'; +print '
'."\n"; + print ''; if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($langs->trans("Login"),$_SERVER['PHP_SELF'],"u.login",$param,"","",$sortfield,$sortorder); if (! empty($arrayfields['u.lastname']['checked'])) print_liste_field_titre($langs->trans("Lastname"),$_SERVER['PHP_SELF'],"u.lastname",$param,"","",$sortfield,$sortorder); @@ -655,9 +658,10 @@ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // N print $hookmanager->resPrint; print "
"; +print '
'; print "\n"; -$db->free($result); +$db->free($result); llxFooter(); $db->close(); diff --git a/htdocs/user/note.php b/htdocs/user/note.php index ccd7eb153a4..e2feb378f3c 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -112,7 +112,7 @@ if ($id) print "id."\">"; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note_private',$object->note,'',280,'dolibarr_notes','In',true,false,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,80); + $doleditor=new DolEditor('note_private',$object->note,'',280,'dolibarr_notes','In',true,false,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_8,'90%'); $doleditor->Create(); } else diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 17979db0989..69143108e66 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -978,7 +978,7 @@ if ($action == 'editcontent') $contentforedit .= $objectpage->content; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,5,60); + $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); $doleditor->Create(0, '', false); } diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index f967b53d9db..786970e2b3a 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -367,6 +367,14 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $after=dol_string_nohtmltag($text, 1); $this->assertEquals("A string with tag with < chars",$after,"test3"); + $text="A string
Another string"; + $after=dol_string_nohtmltag($text,0); + $this->assertEquals("A string\nAnother string",$after,"test4"); + + $text="A string
Another string"; + $after=dol_string_nohtmltag($text,1); + $this->assertEquals("A string Another string",$after,"test5"); + return true; }