diff --git a/ChangeLog b/ChangeLog index 32277ea29ae..c6b3ee2d89b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,11 @@ Following changes may create regressions for some external modules, but were nec ***** ChangeLog for 10.0.3 compared to 10.0.2 ***** +IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. +The unit were not saved correctly in database making calculation on shipments wrong. +Update to this version must be done if you use them and have installed version 10.0.0, 10.0.1 or 10.0.2 and set some products after installing or upgrading to this version. +Once update is done you must then edit (manually) the product that has bad unit to set the correct unit to have features restored. + FIX: #11702 FIX: #11861 No consistent code to manage measuring units FIX: #11942 diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php index 54e17c7f8d7..f1e0f4f360b 100755 --- a/dev/initdata/generate-thirdparty.php +++ b/dev/initdata/generate-thirdparty.php @@ -116,7 +116,6 @@ for ($s = 0 ; $s < GEN_NUMBER_SOCIETE ; $s++) $contact->firstname = $listoflastname[mt_rand(0, count($listoflastname)-1)]; if ( $contact->create($user) ) { - } } diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 6773e1d2c03..32c44ce91e4 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -122,14 +122,14 @@ - + 0 0 - + @@ -195,7 +195,7 @@ --> - + @@ -213,6 +213,8 @@ 0 + + @@ -337,7 +339,7 @@ - @@ -375,7 +377,7 @@ 0 - + 0 diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 06a2fb60d67..2f23cd3eae8 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -677,7 +677,6 @@ if ($id) { foreach ($fieldlist as $field => $value) { - $showfield=1; $class="left"; $valuetoshow=$obj->{$fieldlist[$field]}; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index c49ed42741b..f54c477ff52 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -273,7 +273,6 @@ if ($action == 'create') { print ''; } elseif ($id > 0 || $ref) { - $result = $object->fetch($id, $ref, 1); if ($result > 0) { diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index a7fe40acefc..5fdd43eb020 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -130,7 +130,6 @@ if (! empty($cat_id)) } if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { - print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, null, null, "90%"); print '
'; /*print ''; print ''; foreach ($list_account_main as $key) { - print ''; // Param $label = $langs->trans($key); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 13d3a267956..6b47578761c 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -83,7 +83,6 @@ if (GETPOST('change_chart', 'alpha')) $chartofaccounts = GETPOST('chartofaccounts', 'int'); if (! empty($chartofaccounts)) { - if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error ++; } @@ -144,7 +143,6 @@ print ''; print '
'; foreach ($list_account_main as $key) { - print ''; // Param $label = $langs->trans($key); @@ -172,7 +170,6 @@ print '
'; print '
'; foreach ($list_account as $key) { - print ''; // Param $label = $langs->trans($key); diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index e13a66998b7..e506f5bf512 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -114,7 +114,7 @@ if ($action == 'update') { $error ++; } } - } + } if (! $error) { // reload @@ -203,7 +203,6 @@ print "\n"; $num = count($main_option); if ($num) { foreach ($main_option as $key) { - print ''; // Param diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 5cc03376808..03404bd4126 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -45,7 +45,7 @@ $langs->loadLangs(array("admin","compta")); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we should be able to see fiscal year. +if (! $user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year. accessforbidden(); $error = 0; @@ -112,7 +112,7 @@ if ($result) $i = 0; - $addbutton.= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear); + $addbutton.= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); $title = $langs->trans('AccountingPeriods'); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index f12aaba054b..d9125a686c6 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -33,7 +33,7 @@ $langs->loadLangs(array("admin","compta")); // Security check if ($user->societe_id > 0) accessforbidden(); -if (empty($user->rights->accounting->fiscalyear)) +if (empty($user->rights->accounting->fiscalyear->write)) accessforbidden(); $error = 0; @@ -300,7 +300,7 @@ if ($action == 'create') dol_fiche_end(); - if (! empty($user->rights->accounting->fiscalyear)) + if (! empty($user->rights->accounting->fiscalyear->write)) { /* * Barre d'actions diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index cfe6c20bd7b..dd62352e2b1 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -32,7 +32,7 @@ $langs->loadLangs(array("admin","compta")); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear) +if (! $user->rights->accounting->fiscalyear->write) accessforbidden(); $id = GETPOST('id', 'int'); diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index fcdf4de032c..44fe3e936cd 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -609,7 +609,6 @@ if ($id) $langs->load("accountancy"); foreach ($fieldlist as $field => $value) { - $showfield=1; $class="left"; $valuetoshow=$obj->{$fieldlist[$field]}; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 2922d3bdf23..091018dc909 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -117,7 +117,6 @@ if ($action == 'update') { ); if (in_array($accounting_product_mode, $accounting_product_modes)) { - if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { $error ++; } @@ -129,7 +128,6 @@ if ($action == 'update') { if (! empty($btn_changeaccount)) { //$msg = '
' . $langs->trans("Processing") . '...
'; if (! empty($chk_prod)) { - $accounting = new AccountingAccount($db); //$msg .= '
' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
'; diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index d0e9b940074..bdc78911513 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -105,7 +105,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $i < $num ) { - $row = $db->fetch_row($resql); print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 5f9ba37d341..cc6307bae2c 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -83,7 +83,6 @@ $object = new BookKeeping($db); */ if ($action == "confirm_update") { - $error = 0; if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { @@ -585,7 +584,6 @@ if ($action == 'create') if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print ''; @@ -601,7 +599,6 @@ if ($action == 'create') print "
' . length_accountg($row[0]) . '
"; if (count($object->linesmvt) > 0) { - $total_debit = 0; $total_credit = 0; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 2958a229d24..5158e12ebb6 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -155,6 +155,12 @@ $arrayfields=array( if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); +$listofformat=AccountancyExport::getType(); +$formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV; +if (empty($listofformat[$formatexportset])) $formatexportset = 1; + +$error = 0; + /* * Actions @@ -310,7 +316,6 @@ if (empty($reshook)) } if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { - $import_key = GETPOST('importkey', 'alpha'); if (! empty($import_key)) { @@ -325,7 +330,6 @@ if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->suppri } } if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { - $delyear = GETPOST('delyear', 'int'); if ($delyear==-1) { $delyear=0; @@ -356,7 +360,6 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme } } if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { - $mvt_num = GETPOST('mvt_num', 'int'); if (! empty($mvt_num)) { @@ -373,10 +376,96 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri exit; } } +if ($action == 'setreexport') { + $setreexport = GETPOST('value', 'int'); + if (! dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++; + + if (! $error) { + if ($conf->global->ACCOUNTING_REEXPORT == 1) { + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); + } + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +// Build and execute select (used by page and export action) +// must de set after the action that set $filter +// -------------------------------------------------------------------- + +$sql = 'SELECT'; +$sql .= ' t.rowid,'; +$sql .= " t.doc_date,"; +$sql .= " t.doc_type,"; +$sql .= " t.doc_ref,"; +$sql .= " t.fk_doc,"; +$sql .= " t.fk_docdet,"; +$sql .= " t.thirdparty_code,"; +$sql .= " t.subledger_account,"; +$sql .= " t.subledger_label,"; +$sql .= " t.numero_compte,"; +$sql .= " t.label_compte,"; +$sql .= " t.label_operation,"; +$sql .= " t.debit,"; +$sql .= " t.credit,"; +$sql .= " t.lettering_code,"; +$sql .= " t.montant,"; +$sql .= " t.sens,"; +$sql .= " t.fk_user_author,"; +$sql .= " t.import_key,"; +$sql .= " t.code_journal,"; +$sql .= " t.journal_label,"; +$sql .= " t.piece_num,"; +$sql .= " t.date_creation,"; +$sql .= " t.tms as date_modification,"; +$sql .= " t.date_export"; +$sql .= ' FROM ' . MAIN_DB_PREFIX . $object->table_element . ' as t'; +// Manage filter +$sqlwhere = array (); +if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.doc_date') { + $sqlwhere[] = $key . '=\'' . $db->idate($value) . '\''; + } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { + $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { + $sqlwhere[] = $key . '\'' . $db->escape($value) . '\''; + } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { + $sqlwhere[] = $key . '=' . $value; + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { + $sqlwhere[] = $key . ' LIKE \'' . $db->escape($value) . '%\''; + } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { + $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + } elseif ($key == 't.tms>=' || $key == 't.tms<=') { + $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { + $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + } elseif ($key == 't.credit' || $key == 't.debit') { + $sqlwhere[] = natural_search($key, $value, 1, 1); + } else { + $sqlwhere[] = natural_search($key, $value, 0, 1); + } + } +} +$sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')'; +if ($conf->global->ACCOUNTING_REEXPORT == 0) { + $sql .= " AND t.date_export IS NULL"; +} +if (count($sqlwhere) > 0) { + $sql .= ' AND ' . implode(' AND ', $sqlwhere); +} +if (! empty($sortfield)) { + $sql .= $db->order($sortfield, $sortorder); +} +//print $sql; + // Export into a file with format defined into setup (FEC, CSV, ...) +// Must be after definition of $sql if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { - + // TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them. $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT); if ($result < 0) @@ -387,55 +476,54 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { { // Export files $accountancyexport = new AccountancyExport($db); - $accountancyexport->export($object->lines); + $accountancyexport->export($object->lines, $formatexportset); if (! empty($accountancyexport->errors)) { setEventMessages('', $accountancyexport->errors, 'errors'); - } else { + } + else + { // Specify as export : update field date_export - // TODO Move in class bookKeeping $error=0; $db->begin(); - if (is_array($object->lines)) { - foreach ($object->lines as $movement) { + if (is_array($object->lines)) + { + foreach ($object->lines as $movement) + { $now = dol_now(); + $sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " SET date_export = '" . $db->idate($now) . "'"; $sql .= " WHERE rowid = " . $movement->id; dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); - if ($result) { - $db->commit(); - // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); - } else { - $db->rollback(); - // setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); + if (! $result) + { + $error++; + break; } } } + + if (! $error) + { + $db->commit(); + // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); + } + else + { + $error++; + $db->rollback(); + setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); + } } exit; } } -if ($action == 'setreexport') { - $export = 0; - $setreexport = GETPOST('value', 'int'); - if (! dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++; - - if (! $error) { - if ($conf->global->ACCOUNTING_REEXPORT == 1) { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); - } - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} /* * View @@ -443,31 +531,49 @@ if ($action == 'setreexport') { $title_page = $langs->trans("Bookkeeping"); -llxHeader('', $title_page); - -// List +// Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT); - if ($nbtotalofrecords < 0) { - setEventMessages($object->error, $object->errors, 'errors'); +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { + $page = 0; + $offset = 0; } } +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); -// TODO Do not use this -$result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT); -if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); } -$num=count($object->lines); + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title_page); + if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num').$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); print $formconfirm; } if ($action == 'delbookkeepingyear') { - $form_question = array (); $delyear = GETPOST('delyear'); $deljournal = GETPOST('deljournal'); @@ -510,9 +616,6 @@ print ''; print ''; print ''; -$button .= ''; - -$listofformat=AccountancyExport::getType(); if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); else $buttonLabel = $langs->trans("ExportList"); @@ -524,13 +627,13 @@ if (! empty($conf->global->ACCOUNTING_REEXPORT)) { } $newcardbutton.= ''.$langs->trans("IncludeDocsAlreadyExported").''; -$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export); +$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export); $newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); $newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer); -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -650,7 +753,6 @@ if (! empty($arrayfields['t.code_journal']['checked'])) print ''; } - // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -727,171 +829,200 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -if ($num > 0) +$line = new BookKeepingLine(); + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + $line->id = $obj->rowid; + $line->doc_date = $db->jdate($obj->doc_date); + $line->doc_type = $obj->doc_type; + $line->doc_ref = $obj->doc_ref; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->montant; + $line->sens = $obj->sens; + $line->lettering_code = $obj->lettering_code; + $line->fk_user_author = $obj->fk_user_author; + $line->import_key = $obj->import_key; + $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; + $line->piece_num = $obj->piece_num; + $line->date_creation = $db->jdate($obj->date_creation); + $line->date_modification = $db->jdate($obj->date_modification); + $line->date_export = $db->jdate($obj->date_export); + + $total_debit += $line->debit; + $total_credit += $line->credit; + + print ''; + + // Piece number + if (! empty($arrayfields['t.piece_num']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Document date + if (! empty($arrayfields['t.doc_date']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Document ref + if (! empty($arrayfields['t.doc_ref']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Account number + if (! empty($arrayfields['t.numero_compte']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Subledger account + if (! empty($arrayfields['t.subledger_account']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Label operation + if (! empty($arrayfields['t.label_operation']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Amount debit + if (! empty($arrayfields['t.debit']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield']; + $totalarray['totaldebit'] += $line->debit; + } + + // Amount credit + if (! empty($arrayfields['t.credit']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield']; + $totalarray['totalcredit'] += $line->credit; + } + + // Lettering code + if (! empty($arrayfields['t.lettering_code']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Journal code + if (! empty($arrayfields['t.code_journal']['checked'])) + { + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $line->code_journal); + $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Creation operation date + if (! empty($arrayfields['t.date_creation']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Modification operation date + if (! empty($arrayfields['t.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Exported operation date + if (! empty($arrayfields['t.date_export']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Action column + print ''; + + if (! $i) $totalarray['nbfield']++; + + print "\n"; + + $i++; +} + +// Show total line +if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield'])) { $i=0; - $totalarray=array(); - while ($i < min($num, $limit)) + print ''; + while ($i < $totalarray['nbfield']) { - $line = $object->lines[$i]; - - $total_debit += $line->debit; - $total_credit += $line->credit; - - print ''; - - // Piece number - if (! empty($arrayfields['t.piece_num']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Document date - if (! empty($arrayfields['t.doc_date']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Document ref - if (! empty($arrayfields['t.doc_ref']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Account number - if (! empty($arrayfields['t.numero_compte']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Subledger account - if (! empty($arrayfields['t.subledger_account']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Label operation - if (! empty($arrayfields['t.label_operation']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Amount debit - if (! empty($arrayfields['t.debit']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield']; - $totalarray['totaldebit'] += $line->debit; - } - - // Amount credit - if (! empty($arrayfields['t.credit']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield']; - $totalarray['totalcredit'] += $line->credit; - } - - // Lettering code - if (! empty($arrayfields['t.lettering_code']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Journal code - if (! empty($arrayfields['t.code_journal']['checked'])) - { - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $line->code_journal); - $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Creation operation date - if (! empty($arrayfields['t.date_creation']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Modification operation date - if (! empty($arrayfields['t.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Exported operation date - if (! empty($arrayfields['t.date_export']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Action column - print ''; - - if (! $i) $totalarray['nbfield']++; - - print "\n"; - $i++; - } - - // Show total line - if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield'])) - { - $i=0; - print ''; - while ($i < $totalarray['nbfield']) + if ($i == 1) { - $i++; - if ($i == 1) - { - if ($num < $limit && empty($offset)) print ''; - else print ''; - } - elseif ($totalarray['totaldebitfield'] == $i) print ''; - elseif ($totalarray['totalcreditfield'] == $i) print ''; - else print ''; + if ($num < $limit && empty($offset)) print ''; + else print ''; } - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print ''; + elseif ($totalarray['totaldebitfield'] == $i) print ''; + elseif ($totalarray['totalcreditfield'] == $i) print ''; + else print ''; } + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print ''; } + print "
'; + $object->id = $line->id; + $object->piece_num = $line->piece_num; + print $object->getNomUrl(1, '', 0, '', 1); + print '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->subledger_account) . '' . $line->label_operation . '' . ($line->debit ? price($line->debit) : ''). '' . ($line->credit ? price($line->credit) : '') . '' . $line->lettering_code . '' . $journaltoshow . '' . dol_print_date($line->date_creation, 'dayhour') . '' . dol_print_date($line->date_modification, 'dayhour') . '' . dol_print_date($line->date_export, 'dayhour') . ''; + if (empty($line->date_export)) { + if ($user->rights->accounting->mouvements->creer) { + print '' . img_edit() . ''; + } + if ($user->rights->accounting->mouvements->supprimer) { + print ' ' . img_delete() . ''; + } + } + print '
'; - $object->id = $line->id; - $object->piece_num = $line->piece_num; - print $object->getNomUrl(1, '', 0, '', 1); - print '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->subledger_account) . '' . $line->label_operation . '' . ($line->debit ? price($line->debit) : ''). '' . ($line->credit ? price($line->credit) : '') . '' . $line->lettering_code . '' . $journaltoshow . '' . dol_print_date($line->date_creation, 'dayhour') . '' . dol_print_date($line->date_modification, 'dayhour') . '' . dol_print_date($line->date_export, 'dayhour') . ''; - if (empty($line->date_export)) { - if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; - } - if ($user->rights->accounting->mouvements->supprimer) { - print ' ' . img_delete() . ''; - } - } - print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totaldebit']).''.price($totalarray['totalcredit']).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.price($totalarray['totaldebit']).''.price($totalarray['totalcredit']).'
"; print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index d91772a6ab3..4f275e3e2b0 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -179,7 +179,6 @@ if (! empty($search_credit)) { if ($action == 'delmouvconfirm') { - $mvt_num = GETPOST('mvt_num', 'int'); if (! empty($mvt_num)) { @@ -229,7 +228,6 @@ if ($action == 'delmouv') { print $formconfirm; } if ($action == 'delbookkeepingyear') { - $form_question = array (); $delyear = GETPOST('delyear'); @@ -338,7 +336,6 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { - // Affiche un Sous-Total par compte comptable if (isset($displayed_account_number)) { print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index b7a19101758..4bc60fc904f 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -100,7 +100,6 @@ if ($result < 0) */ if ($action == 'lettering') { - $result = $lettering->updateLettering($toselect); if ($result < 0) { @@ -251,7 +250,6 @@ if ($resql) { $tmp = ''; while ( $obj = $db->fetch_object($resql) ) { - if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index eaa741e1722..df513f8d074 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -99,7 +99,6 @@ if ($result<0) * Action */ if ($action == 'lettering') { - $result = $lettering->updateLettering($toselect); if ($result < 0) { @@ -248,7 +247,6 @@ if ($resql) { $solde = 0; $tmp = ''; while ($obj = $db->fetch_object($resql)) { - if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index f90d5797d09..7e8f14f2a53 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -224,22 +224,23 @@ class AccountancyExport /** * Function who chose which export to use with the default config, and make the export into a file * - * @param array $TData data - * @return void + * @param array $TData Array with data + * @param int $formatexportset Id of export format + * @return void */ - public function export(&$TData) + public function export(&$TData, $formatexportset) { global $conf, $langs; global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php // Define name of file to save - $filename = 'general_ledger-'.$this->getFormatCode($conf->global->ACCOUNTING_EXPORT_MODELCSV); + $filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $type_export = 'general_ledger'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) { + switch ($formatexportset) { case self::$EXPORT_TYPE_CONFIGURABLE : $this->exportConfigurable($TData); break; @@ -548,7 +549,6 @@ class AccountancyExport $end_line = "\n"; foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d%m%Y'); print $line->id . $separator; @@ -584,7 +584,6 @@ class AccountancyExport $end_line = "\n"; foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d%m%Y'); print $line->piece_num . $separator; @@ -624,7 +623,6 @@ class AccountancyExport $end_line = "\n"; foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); print $date . $separator; @@ -933,7 +931,6 @@ class AccountancyExport $end_line = "\r\n"; foreach ($objectLines as $line) { - $date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); @@ -1086,7 +1083,6 @@ class AccountancyExport print $end_line; foreach($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%Y%m%d'); print $date . $separator; //Date diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index f9c2e3391ba..21cbdeb9662 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -407,7 +407,6 @@ class AccountingAccount extends CommonObject $result = $this->checkUsage(); if ($result > 0) { - $this->db->begin(); // if (! $error) { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 16dc458d833..b4e747d65f3 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1584,9 +1584,7 @@ class BookKeeping extends CommonObject dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - while ($obj = $this->db->fetch_object($result)) { - $line = new BookKeepingLine(); $line->id = $obj->rowid; @@ -1966,6 +1964,7 @@ class BookKeepingLine public $credit; public $montant; public $sens; + public $lettering_code; /** * @var int ID @@ -1977,4 +1976,6 @@ class BookKeepingLine public $journal_label; public $piece_num; public $date_creation; + public $date_modification; + public $date_export; } diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index e20b49dbd25..ef63fc8b15f 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -149,7 +149,6 @@ class Lettering extends BookKeeping } } } elseif ($obj->type == 'payment') { - $sql = 'SELECT DISTINCT bk.rowid, fac.ref, fac.ref, pay.fk_bank, fac.rowid as fact_id'; $sql .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; diff --git a/htdocs/accountancy/closure/index.html b/htdocs/accountancy/closure/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php new file mode 100644 index 00000000000..ea04cb82b0a --- /dev/null +++ b/htdocs/accountancy/closure/index.php @@ -0,0 +1,132 @@ + + * + * 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 . + * + */ + +/** + * \file htdocs/accountancy/closure/index.php + * \ingroup Accountancy + * \brief Home closure page + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("compta","bills","other","main","accountancy")); + +// Security check +if (empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->fiscalyear->write) + accessforbidden(); + + +$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); +else +{ + $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year +} +$year_end = $year_start + 1; +$month_end = $month_start - 1; +if ($month_end < 1) +{ + $month_end = 12; + $year_end--; +} +$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); +$search_date_end = dol_get_last_day($year_end, $month_end); +$year_current = $year_start; + +/* + * Actions + */ + + +/* + * View + */ + +llxHeader('', $langs->trans("Closure")); + +$textprevyear = '' . img_previous() . ''; +$textnextyear = ' ' . img_next() . ''; + + +print load_fiche_titre($langs->trans("Closure") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); + +print $langs->trans("DescClosure") . '
'; +print '
'; + + +$y = $year_current; + +$buttonbind = '' . $langs->trans("ValidateMovements") . ''; + +print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); + +print '
'; +print ''; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + print ''; +} +print ''; + +$sql = "SELECT COUNT(b.rowid) as detail,"; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + $sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " COUNT(b.rowid) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; +$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'"; +$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'"; +$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy + +dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[$i] . '' . $row[13] . '
\n"; +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php new file mode 100644 index 00000000000..748da9fe24d --- /dev/null +++ b/htdocs/accountancy/closure/validate.php @@ -0,0 +1,158 @@ + + * + * 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 . + * + */ + +/** + * \file htdocs/accountancy/closure/validate.php + * \ingroup Accountancy + * \brief Validate entries page + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("compta","bills","other","main","accountancy")); + +// Security check +if (empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->societe_id > 0) + accessforbidden(); + if (! $user->rights->accounting->fiscalyear->write) + accessforbidden(); + + +$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); +else +{ + $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year +} +$year_end = $year_start + 1; +$month_end = $month_start - 1; +if ($month_end < 1) +{ + $month_end = 12; + $year_end--; +} +$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); +$search_date_end = dol_get_last_day($year_end, $month_end); +$year_current = $year_start; + +/* + * Actions + */ + +if ($action == 'validate') +{ + $now = dol_now(); + + // Update database + $db->begin(); + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; + $sql .= " SET b.date_validated = '" . $db->idate($now) . "'"; + $sql .= ' WHERE b.date_validated IS NULL'; + + dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); + $resql = $db->query($sql); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + } + // End clean database +} + + +/* + * View + */ + +llxHeader('', $langs->trans("ValidateMovements")); + +$textprevyear = '' . img_previous() . ''; +$textnextyear = ' ' . img_next() . ''; + + +print load_fiche_titre($langs->trans("ValidateMovements") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); + +print $langs->trans("DescValidateMovements") . '
'; +print '
'; + + +$y = $year_current; + +print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', '', -1, '', '', 0, '', 'class="right"', 0, 1, 1); + +print '
'; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + print ''; +} +print ''; + +print ''; +$sql = "SELECT COUNT(b.rowid) as detail,"; +for($i = 1; $i <= 12; $i ++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; + if ($j > 12) $j-=12; + $sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " COUNT(b.rowid) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; +$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'"; +$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'"; +$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy + +dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + for($i = 1; $i <= 12; $i ++) { + print '' ; + } + print ''; + } + print + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print ''; +print "
' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[$i] . '

'; + print ''; + print '
' . $row[13] . '
\n"; + +print '
'; +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 52057485a30..00c4a945ff9 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -112,7 +112,6 @@ if (! empty($id)) { $i = 0; if ($num_lines) { - $objp = $db->fetch_object($result); print '' . "\n"; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 68649aa264d..f43ca801c25 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -97,7 +97,6 @@ if ($action == 'clean' || $action == 'validatehistory') } if ($action == 'validatehistory') { - $error = 0; $db->begin(); @@ -195,7 +194,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print ''; if ($row[0] == 'tobind') { @@ -271,7 +269,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print ''; if ($row[0] == 'tobind') { @@ -398,7 +395,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print '' . $row[0] . ''; for($i = 1; $i <= 12; $i ++) { print '' . price(price2num($row[$i])) . ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index d3fc63d3bf8..ea855921c5a 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -94,7 +94,6 @@ if ($action == 'clean' || $action == 'validatehistory') } if ($action == 'validatehistory') { - $error = 0; $db->begin(); @@ -187,7 +186,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print ''; if ($row[0] == 'tobind') { @@ -259,7 +257,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print ''; if ($row[0] == 'tobind') { diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b36da4a2855..6e709835f42 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -4,7 +4,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2019 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2017-2018 Frédéric France @@ -167,7 +167,6 @@ $journal_label = $accountingjournalstatic->label; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); //print $sql; @@ -268,10 +267,8 @@ if ($result) { // get_url may return -1 which is not traversable if (is_array($links) && count($links) > 0) { - // Now loop on each link of record in bank. foreach ($links as $key => $val) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) { // So we excluded 'company' and 'user' here. We want only payment lines @@ -387,7 +384,9 @@ if ($result) { $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; $paymentvariousstatic->fetch($paymentvariousstatic->id); $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word - $tabtp[$obj->rowid][$account_various] += $obj->amount; + $account_subledger = (! empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word + $tabpay[$obj->rowid]["account_various"] = $account_various; + $tabtp[$obj->rowid][$account_subledger] += $obj->amount; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id']; @@ -660,11 +659,11 @@ if (! $error && $action == 'writebookkeeping') { $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_various') { - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; + $bookkeeping->subledger_account = $k; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $tabpay[$obj->rowid]["account_various"]; - $accountingaccount->fetch(null, $k, true); + $accountingaccount->fetch(null, $bookkeeping->numero_compte, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'banktransfert') { $bookkeeping->subledger_account = ''; @@ -1123,6 +1122,7 @@ if (empty($action) || $action == 'view') { if ($tabtype[$key] == 'payment_salary') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; + if ($tabtype[$key] == 'payment_various') $account_ledger = $tabpay[$key]["account_various"]; $accounttoshow = length_accounta($account_ledger); if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { @@ -1156,7 +1156,7 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; - if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary'))) // Type of payment with subledger + if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) // Type of payment with subledger { $accounttoshowsubledger = length_accounta($k); if ($accounttoshow != $accounttoshowsubledger) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 23d97360563..6cefc893b39 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -115,7 +115,6 @@ $sql .= " ORDER BY er.date_debut"; dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { - $taber = array (); $tabht = array (); $tabtva = array (); @@ -485,7 +484,6 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } if (empty($action) || $action == 'view') { - llxHeader('', $langs->trans("ExpenseReportsJournal")); $nom = $langs->trans("ExpenseReportsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index c83c004c6b2..ddf456c85f0 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -242,7 +242,6 @@ if ($action == 'writebookkeeping') { $invoicestatic = new FactureFournisseur($db); foreach ($tabfac as $key => $val) { // Loop on each invoice - $errorforline = 0; $totalcredit = 0; @@ -716,7 +715,6 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } if (empty($action) || $action == 'view') { - llxHeader('', $langs->trans("PurchasesJournal")); $nom = $langs->trans("PurchasesJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 17b2657b5dc..ed56065df0a 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -255,7 +255,6 @@ if ($action == 'writebookkeeping') { $invoicestatic = new Facture($db); foreach ($tabfac as $key => $val) { // Loop on each invoice - $errorforline = 0; $totalcredit = 0; @@ -654,7 +653,6 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if (empty($action) || $action == 'view') { - llxHeader('', $langs->trans("SellsJournal")); $nom = $langs->trans("SellsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 88a599d1fc5..faa48ac9176 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -95,7 +95,6 @@ if ($action == 'clean' || $action == 'validatehistory') } if ($action == 'validatehistory') { - $error = 0; $db->begin(); @@ -187,7 +186,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print ''; if ($row[0] == 'tobind') { @@ -258,7 +256,6 @@ if ($resql) { $num = $db->num_rows($resql); while ( $row = $db->fetch_row($resql)) { - print ''; if ($row[0] == 'tobind') { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 22b98289571..94216db5f8c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2367,7 +2367,6 @@ class Adherent extends CommonObject $langs->load("orders"); if (! dol_strlen($modele)) { - $modele = 'standard'; if ($this->modelpdf) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a57a90a3aac..94df4b10ba0 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -383,7 +383,6 @@ class AdherentType extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->description = $this->db->escape($this->note); // Multilangs diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 092827ef731..a6343596632 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -90,7 +90,6 @@ if ($id > 0) $result=$membert->fetch($object->typeid); if ($result > 0) { - // Build file list $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); $totalsize=0; diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 4334a54605b..8e2ec3ba730 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -39,7 +39,6 @@ $langs->load("members"); $total=0; foreach($linkedObjectBlock as $key => $objectlink) { - ?> trans("Subscription"); ?> diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index b24e3361d16..2848ed4119e 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -94,7 +94,6 @@ $hookmanager->initHooks(array('membertypecard','globalcard')); */ if ($cancel) { - $action=''; if (! empty($backtopage)) { diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index a13b7bd1580..3caa3418af5 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -268,7 +268,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Active if (in_array($name, $def)) { - print ''."\n"; if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") { @@ -363,7 +362,6 @@ print ''."\n"; if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; print ''."\n"; print ''.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").''."\n"; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 689202c023d..70b273e2fcc 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -253,7 +253,6 @@ $i = 0; $nbofbank = count($bankorder); while ($i < $nbofbank) { - print ''; print '' . $bankorder[$i][0] . "\n"; print $bankorder[$i][1]; @@ -341,7 +340,6 @@ foreach ($dirmodels as $reldir) { foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir . '/' . $file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 0475cdfccf1..b6c9a5dec9a 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -319,7 +319,6 @@ print ''; // Chemin du binaire genbarcode sous linux if (! isset($_SERVER['WINDIR'])) { - print ''; print ''.$langs->trans("GenbarcodeLocation").''; print ''; @@ -335,7 +334,6 @@ if (! isset($_SERVER['WINDIR'])) // Module products if (! empty($conf->product->enabled)) { - print ''; print ''.$langs->trans("SetDefaultBarcodeTypeProducts").''; print ''; @@ -346,7 +344,6 @@ if (! empty($conf->product->enabled)) // Module thirdparty if (! empty($conf->societe->enabled)) { - print ''; print ''.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; print ''; diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index e5e12d41808..5bf01de1053 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -255,7 +255,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''.$module->name."\n"; print $module->info(); print ''; @@ -381,7 +380,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index ca90c836929..1e158bc7a7f 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -474,7 +474,6 @@ print ''; // Activate FileCache - Developement if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - print ''.$langs->trans("EnableFileCache").''; print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1); print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index cb07d741a06..5bb2dbe79ed 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -282,7 +282,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) { if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -299,7 +298,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''.$module->name."\n"; print $module->info(); print ''; @@ -423,7 +421,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index dde962fe9bc..e6ea9a2cb17 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -470,7 +470,6 @@ print ''."\n"; // Barcode if (! empty($conf->barcode->enabled)) { - print ''; print ''; print ''; @@ -555,7 +554,6 @@ print ''; // ProfID1 if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { - print ''; if (! empty($mysoc->country_code)) { @@ -571,7 +569,6 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') // ProfId2 if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { - print ''; if (! empty($mysoc->country_code)) { @@ -587,7 +584,6 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') // ProfId3 if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { - print ''; if (! empty($mysoc->country_code)) { @@ -603,7 +599,6 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') // ProfId4 if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { - print ''; if (! empty($mysoc->country_code)) { @@ -619,7 +614,6 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') // ProfId5 if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { - print ''; if (! empty($mysoc->country_code)) { @@ -635,7 +629,6 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') // ProfId6 if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { - print ''; if (! empty($mysoc->country_code)) { diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index bb2bfdde409..0955d7c6d17 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -68,7 +68,6 @@ if ($action == 'update') if (in_array($accounting_mode, $accounting_modes)) { - if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { $error++; } diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 53555a35586..37559c3d4ab 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -118,7 +118,6 @@ if (! empty($consts) && $action == 'update') // Mass delete if (! empty($consts) && $action == 'delete') { - $nbdeleted=0; foreach($consts as $const) { diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index e6c8c15c0d4..0aa97dd36e6 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -219,7 +219,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) { if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -236,7 +235,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''.$module->nom."\n"; print $module->info(); print ''; @@ -359,7 +357,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index d69a14deb2e..7e724c52280 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -265,7 +265,6 @@ print '
'; print ''.$langs->trans("DescWeather").' '; if($action == 'edit') { - $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; @@ -292,8 +291,6 @@ $text=''; $options='class="valignmiddle" height="60px"'; if ($action == 'edit') { - - print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>'; print '
'; @@ -364,9 +361,7 @@ if ($action == 'edit') { global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - print '
'; print '
'; print img_weather($text, 0, $options); @@ -386,7 +381,6 @@ if ($action == 'edit') { print '
'; print '
'; } else { - print '
'; print '
'; print img_weather($text, 0, $options); @@ -411,11 +405,9 @@ if ($action == 'edit') { print '
'; if($action == 'edit') { - print '
'; print '
'; } else { - print '
'; } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 6c498d30867..b39f0a8d143 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1740,7 +1740,6 @@ else { if ($showemptyline) { - print '   '; $showemptyline=0; } diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 4951f57c22f..e65eb2bbb0a 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -226,7 +226,6 @@ class Dolistore $html .= self::get_categories($cat->id); $html .= "\n"; } else { - } } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index e8dbfab9942..29ef6d40a1e 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -366,7 +366,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 8dde3449b6e..8a5cef82ceb 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -247,7 +247,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - print ''.$module->nom."\n"; print $module->info(); print ''; @@ -367,10 +366,8 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index d16f3e493f5..e3adeaca890 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -300,7 +300,6 @@ if ($resql) // Logo if ($result > 0 && empty($rss->error)) { - print ''; print "".$langs->trans("Logo").""; print ''; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 759038930ef..dccfcdfdda1 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -720,7 +720,6 @@ if ($resql) $i = 0; while ($i < $num) { - $row = $db->fetch_row($resql); print '

"; @@ -379,7 +378,6 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) } else { - print ''.$langs->trans("NoOrder").''; } print ""; @@ -430,7 +428,6 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { - $obj = $db->fetch_object($resql); print ''; $supplierorderstatic->id=$obj->rowid; @@ -470,7 +467,6 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande } else { - print ''.$langs->trans("NoSupplierOrder").''; } print ""; diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 9544a394508..1049431b7f2 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -114,7 +114,6 @@ if ($action == 'loadfilter') { } if ($action == 'add') { - $user_contact_query = false; $array_query = array (); @@ -168,7 +167,6 @@ if ($action == 'add') { } if (preg_match("/^contact_/", $key)) { - $array_query[$key] = GETPOST($key); $specials_date_key = array ( @@ -262,7 +260,6 @@ if ($action == 'clear') { } if ($action == 'savefilter' || $action == 'createfilter') { - $template_name = GETPOST('template_name'); $error = 0; @@ -272,7 +269,6 @@ if ($action == 'savefilter' || $action == 'createfilter') { } if (empty($error)) { - $array_query = array (); // Get extra fields @@ -325,7 +321,6 @@ if ($action == 'savefilter' || $action == 'createfilter') { } if (preg_match("/^contact_/", $key)) { - $array_query[$key] = GETPOST($key); $specials_date_key = array ( @@ -359,7 +354,6 @@ if ($action == 'savefilter' || $action == 'createfilter') { setEventMessages($advTarget->error, $advTarget->errors, 'errors'); } } elseif ($action == 'savefilter') { - $result = $advTarget->update($user); if ($result < 0) { setEventMessages($advTarget->error, $advTarget->errors, 'errors'); @@ -421,7 +415,6 @@ $formcompany = new FormCompany($db); $formother = new FormOther($db); if ($object->fetch($id) >= 0) { - $head = emailing_prepare_head($object); dol_fiche_head($head, 'advtargets', $langs->trans("Mailing"), 0, 'email'); @@ -465,7 +458,6 @@ if ($object->fetch($id) >= 0) { // Show email selectors if ($object->statut == 0 && $user->rights->mailing->creer) { - include DOL_DOCUMENT_ROOT . '/core/tpl/advtarget.tpl.php'; } } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 7346bf87543..465bf7dcc50 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -556,7 +556,6 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]= 't.entity IN ('.getEntity('societe').')'; if (count($arrayquery)>0) { - if (array_key_exists('cust_saleman', $arrayquery)) { $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as saleman ON saleman.fk_soc=t.rowid "; } @@ -565,7 +564,6 @@ class AdvanceTargetingMailing extends CommonObject } if (!empty($arrayquery['cust_name'])) { - $sqlwhere[]= $this->transformToSQL('t.nom', $arrayquery['cust_name']); } if (!empty($arrayquery['cust_code'])) { @@ -617,13 +615,11 @@ class AdvanceTargetingMailing extends CommonObject //Standard Extrafield feature if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $elementtype = Societe::$table_element; $extrafields->fetch_name_optionals_label($elementtype); foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key])) { @@ -713,7 +709,6 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]= 't.entity IN ('.getEntity('socpeople').')'; if (count($arrayquery)>0) { - if (array_key_exists('contact_categ', $arrayquery)) { $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_contact as contactcateg ON contactcateg.fk_socpeople=t.rowid "; } @@ -767,7 +762,6 @@ class AdvanceTargetingMailing extends CommonObject $extrafields->fetch_name_optionals_label($elementtype); foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key.'_cnct'])) { @@ -809,7 +803,6 @@ class AdvanceTargetingMailing extends CommonObject } if (!empty($arrayquery['cust_name'])) { - $sqlwhere[]= $this->transformToSQL('ts.nom', $arrayquery['cust_name']); } if (!empty($arrayquery['cust_code'])) { @@ -870,7 +863,6 @@ class AdvanceTargetingMailing extends CommonObject $extrafields->fetch_name_optionals_label($elementtype); foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key])) { diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 55b7177eb73..67ec7414e7c 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -114,7 +114,6 @@ class FormAdvTargetEmailing extends Form dol_syslog(get_class($this) . "::select_country sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); $i = 0; if ($num) { @@ -175,7 +174,6 @@ class FormAdvTargetEmailing extends Form $resql_usr = $this->db->query($sql_usr); if ($resql_usr) { while ( $obj_usr = $this->db->fetch_object($resql_usr) ) { - $label = $obj_usr->firstname . " " . $obj_usr->name . " (" . $obj_usr->login . ')'; $options_array [$obj_usr->rowid] = $label; @@ -249,7 +247,6 @@ class FormAdvTargetEmailing extends Form $sql = 'SELECT ' . $keyList . ', ' . $InfoFieldList [1]; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList [0]; if (! empty($InfoFieldList [3])) { - // We have to join on extrafield table if (strpos($InfoFieldList [3], 'extra') !== false) { $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList [0] . '_extrafields as extra'; @@ -266,7 +263,6 @@ class FormAdvTargetEmailing extends Form dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); $i = 0; if ($num) { @@ -306,7 +302,6 @@ class FormAdvTargetEmailing extends Form $resql=$this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -396,7 +391,6 @@ class FormAdvTargetEmailing extends Form $resql=$this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -442,8 +436,6 @@ class FormAdvTargetEmailing extends Form dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - - $out .= ''; print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4e72c6312e6..5cd3902b7d1 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -265,7 +265,6 @@ class Account extends CommonObject $string = ''; foreach ($this->getFieldsToShow() as $val) { - if ($val == 'BankCode') { $string .= $this->code_banque.' '; } elseif ($val == 'BankAccountNumber') { @@ -493,7 +492,6 @@ class Account extends CommonObject } if ($accline->insert() > 0) { - if ($categorie>0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; $sql .= "lineid, fk_categ"; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 0d517a43fec..32bfe66f7d1 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -97,7 +97,6 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output . '/' . $object->ref; // Onglets diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 8f87d6f7151..6a143d4a8d1 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -73,7 +73,7 @@ $hookmanager->initHooks(array('bankaccountlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label('bank_account'); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -144,7 +144,9 @@ $accounts = array(); $sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 @@ -514,7 +516,10 @@ foreach ($accounts as $key=>$type) } } } - else print $langs->trans("FeatureDisabled"); + else + { + print ''.$langs->trans("FeatureDisabled").''; + } print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9467cebde59..f264bb074b3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1822,7 +1822,6 @@ if (empty($reshook)) } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); @@ -2327,7 +2326,6 @@ if (empty($reshook)) // Change each progression persent on each lines foreach($object->lines as $line) { - // no traitement for special product if ($line->product_type == 9 ) continue; @@ -3185,7 +3183,6 @@ if ($action == 'create') if (! empty($conf->global->INVOICE_USE_SITUATION)) { if($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY){ - $rwStyle = 'display:none;'; if(GETPOST('type', 'int') == Facture::TYPE_SITUATION){ $rwStyle = ''; @@ -3844,20 +3841,23 @@ elseif ($id > 0 || ! empty($ref)) // Type print '' . $langs->trans('Type') . ''; print $object->getLibType(); + if ($object->module_source) { + print ' ('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; + } if ($object->type == Facture::TYPE_REPLACEMENT) { $facreplaced = new Facture($db); $facreplaced->fetch($object->fk_facture_source); - print ' (' . $langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)) . ')'; + print ' (' . $langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)) . ')'; } if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) { $facusing = new Facture($db); $facusing->fetch($object->fk_facture_source); - print ' (' . $langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)) . ')'; + print ' (' . $langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)) . ')'; } $facidavoir = $object->getListIdAvoirFromInvoice(); if (count($facidavoir) > 0) { - print ' (' . $langs->transnoentities("InvoiceHasAvoir"); + print ' (' . $langs->transnoentities("InvoiceHasAvoir"); $i = 0; foreach ($facidavoir as $id) { if ($i == 0) @@ -3868,19 +3868,19 @@ elseif ($id > 0 || ! empty($ref)) $facavoir->fetch($id); print $facavoir->getNomUrl(1); } - print ')'; + print ')'; } if ($objectidnext > 0) { $facthatreplace = new Facture($db); $facthatreplace->fetch($objectidnext); - print ' (' . $langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)) . ')'; + print ' (' . $langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)) . ')'; } if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, $object->id); if ($result > 0){ - print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'
'; + print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'
'; } } @@ -3888,7 +3888,7 @@ elseif ($id > 0 || ! empty($ref)) { $tmptemplate = new FactureRec($db); $result = $tmptemplate->fetch($object->fk_fac_rec_source); - if ($result > 0) print '. '.$langs->trans("GeneratedFromTemplate", $tmptemplate->ref); + if ($result > 0) print '. '.$langs->trans("GeneratedFromTemplate", $tmptemplate->ref).''; } print ''; @@ -4347,7 +4347,6 @@ elseif ($id > 0 || ! empty($ref)) // List of previous situation invoices if (($object->situation_cycle_ref > 0) && ! empty($conf->global->INVOICE_USE_SITUATION)) { - print ''; @@ -4660,7 +4659,6 @@ elseif ($id > 0 || ! empty($ref)) // Retained warranty : usualy use on construction industry if(!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty){ - // Billed - retained warranty if($object->type == Facture::TYPE_SITUATION) { @@ -4845,20 +4843,20 @@ elseif ($id > 0 || ! empty($ref)) { if ($usercanunvalidate) { - print ''; + print '' . $langs->trans('Modify') . ''; } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } elseif (!$object->is_last_in_cycle()) { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } @@ -4874,9 +4872,9 @@ elseif ($id > 0 || ! empty($ref)) { if ($object->close_code != 'replaced' || (! $objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted { - print ''; + print '' . $langs->trans('ReOpen') . ''; } else { - print '
' . $langs->trans('ReOpen') . '
'; + print '' . $langs->trans('ReOpen') . ''; } } @@ -4884,19 +4882,19 @@ elseif ($id > 0 || ! empty($ref)) if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($usercanvalidate) { - print ''; + print '' . $langs->trans('Validate') . ''; } } // Send by mail if (($object->statut == Facture::STATUS_VALIDATED || $object->statut == Facture::STATUS_CLOSED) || ! empty($conf->global->FACTURE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($objectidnext) { - print '
' . $langs->trans('SendMail') . '
'; + print '' . $langs->trans('SendMail') . ''; } else { if ($usercansend) { - print ''; + print '' . $langs->trans('SendMail') . ''; } else - print ''; + print '' . $langs->trans('SendMail') . ''; } } @@ -4911,7 +4909,7 @@ elseif ($id > 0 || ! empty($ref)) { print ''.$langs->trans("MakeWithdrawRequest").''; } else { - print '
' . $langs->trans('MakeWithdrawRequest') . '
'; + print '' . $langs->trans('MakeWithdrawRequest') . ''; } } else @@ -4930,18 +4928,18 @@ elseif ($id > 0 || ! empty($ref)) { $langs->load("cashdesk"); $receipt_url=DOL_URL_ROOT."/takepos/receipt.php"; - print ''; + print '' . $langs->trans('POSTicket') .''; } // Create payment if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercanissuepayment) { if ($objectidnext) { - print '
' . $langs->trans('DoPayment') . '
'; + print '' . $langs->trans('DoPayment') . ''; } else { //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) // print '
' . $langs->trans('DoPayment') . '
'; //} else { - print ''; + print '' . $langs->trans('DoPayment') . ''; //} } } @@ -4953,27 +4951,27 @@ elseif ($id > 0 || ! empty($ref)) { if ($resteapayer == 0) { - print '
'.$langs->trans('DoPaymentBack').'
'; + print ''.$langs->trans('DoPaymentBack').''; } else { - print ''; + print ''.$langs->trans('DoPaymentBack').''; } } // For standard invoice with excess received if ($object->type == Facture::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) { - print ''; + print ''.$langs->trans('ConvertExcessReceivedToReduc').''; } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) { - print ''; + print '' . $langs->trans('ConvertToReduc') . ''; } // For deposit invoice if ($object->type == Facture::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id)) { - print ''; + print ''.$langs->trans('ConvertToReduc').''; } } @@ -4982,7 +4980,7 @@ elseif ($id > 0 || ! empty($ref)) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) ) { - print ''; + print ''.$langs->trans('ClassifyPaid').''; } // Classify 'closed not completely paid' (possible si validee et pas encore classee payee) @@ -4992,7 +4990,7 @@ elseif ($id > 0 || ! empty($ref)) if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice - print ''; + print '' . $langs->trans('ClassifyPaidPartially') . ''; } else { @@ -5000,11 +4998,11 @@ elseif ($id > 0 || ! empty($ref)) { if ($objectidnext) { - print '
' . $langs->trans('ClassifyCanceled') . '
'; + print '' . $langs->trans('ClassifyCanceled') . ''; } else { - print ''; + print '' . $langs->trans('ClassifyCanceled') . ''; } } } @@ -5013,7 +5011,7 @@ elseif ($id > 0 || ! empty($ref)) // Clone if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) { - print ''; + print '' . $langs->trans("ToClone") . ''; } // Clone as predefined / Create template @@ -5021,7 +5019,7 @@ elseif ($id > 0 || ! empty($ref)) { if (! $objectidnext && count($object->lines) > 0) { - print ''; + print '' . $langs->trans("ChangeIntoRepeatableInvoice") . ''; } } @@ -5030,7 +5028,7 @@ elseif ($id > 0 || ! empty($ref)) { if (! $objectidnext) { - print ''; + print '' . $langs->trans("CreateCreditNote") . ''; } } @@ -5045,9 +5043,9 @@ elseif ($id > 0 || ! empty($ref)) { if ($usercanunvalidate) { - print ''; + print '' . $langs->trans("CreateCreditNote") . ''; } else { - print '
' . $langs->trans("CreateCreditNote") . '
'; + print '' . $langs->trans("CreateCreditNote") . ''; } } @@ -5063,22 +5061,22 @@ elseif ($id > 0 || ! empty($ref)) { if(($object->total_ttc - $totalcreditnotes ) == 0 ) { - print ''; + print '' . $langs->trans("RemoveSituationFromCycle") . ''; } else { - print ''; + print '' . $langs->trans("RemoveSituationFromCycle") . ''; } } // Create next situation invoice if ($usercancreate && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { if ($object->is_last_in_cycle() && $object->situation_final != 1) { - print ''; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } elseif (!$object->is_last_in_cycle()) { - print ''; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } else { - print ''; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } } @@ -5088,31 +5086,31 @@ elseif ($id > 0 || ! empty($ref)) { //var_dump($isErasable); if ($isErasable == -4) { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -3) { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -2) { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -1) { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable <= 0) // Any other cases { - print ''; + print '' . $langs->trans('Delete') . ''; } elseif ($objectidnext) { - print ''; + print '' . $langs->trans('Delete') . ''; } else { - print ''; + print '' . $langs->trans('Delete') . ''; } } else { - print ''; + print '' . $langs->trans('Delete') . ''; } } print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 18d153dc597..9ff90b7b025 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1839,7 +1839,6 @@ class FactureLigneRec extends CommonInvoiceLine $result = $this->db->query($sql); if ($result) { - $objp = $this->db->fetch_object($result); $this->id = $objp->rowid; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6149a161694..84835fa9608 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -848,7 +848,6 @@ class Facture extends CommonInvoice if (! $error) { - $result=$this->update_price(1); if ($result > 0) { @@ -1933,7 +1932,6 @@ class Facture extends CommonInvoice if (! $error) { - $this->ref_client = $ref_client; $this->db->commit(); @@ -3465,7 +3463,6 @@ class Facture extends CommonInvoice $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/facture/"); // Load file with numbering class (if found) @@ -5216,7 +5213,6 @@ class FactureLigne extends CommonInvoiceLine $returnPercent = floatval($res['situation_percent']); if($include_credit_note) { - $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd'; $sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) '; $sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 77abac6e4d1..4642c0b7da1 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -175,15 +175,15 @@ $arrayfields=array( 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>75), 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>80), 'f.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>1, 'position'=>85), - 'f.module_source'=>array('label'=>"Module", 'checked'=>0, 'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS), 'position'=>90), - 'f.pos_source'=>array('label'=>"Terminal", 'checked'=>0, 'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS), 'position'=>91), + 'f.module_source'=>array('label'=>"Module", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS), 'position'=>90), + 'f.pos_source'=>array('label'=>"Terminal", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS), 'position'=>91), 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>95), 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>100), 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1"), 'position'=>110), 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1"), 'position'=>120), 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>130), 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), - 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), + 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), @@ -356,7 +356,6 @@ if ($massaction == 'withdrawrequest') } else { - $db->rollback(); setEventMessages($aBill->error, $aBill->errors, 'errors'); } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 86388fd7e87..e7762b834e4 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -61,7 +61,6 @@ if ($_POST["cancel"] == $langs->trans("Cancel") && ! $id) if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { - $db->begin(); $datev=dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 1e6ab5b4da1..97f97bbc735 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -195,7 +195,6 @@ if($calc ==0 || $calc == 2) { if(($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) !=0) { - $intra = str_replace($find, $replace, $coll->tva_intra); if(empty($intra)) { @@ -269,7 +268,6 @@ if($calc ==0 || $calc == 1){ { if(($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) != 0) { - $intra = str_replace($find, $replace, $coll->tva_intra); if(empty($intra)) { diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 9ab469376e5..3afce69e94b 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -444,7 +444,6 @@ if ($action == 'new') foreach ($accounts as $bid => $account_label) { - print ' '; - + // set cookie by js + $boxcontent.=''; + $this->info_box_contents[0][] = array( + 'tr'=>'class="nohover"', + 'td' => 'class="nohover"', + 'textnoformat' => $boxcontent, + ); $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; @@ -163,11 +169,10 @@ class box_task extends ModeleBoxes $sql.= $this->db->plimit($max, 0); $result = $this->db->query($sql); - $i = 0; + $i = 1; if ($result) { $num = $this->db->num_rows($result); while ($objp = $this->db->fetch_object($result)) { - $taskstatic->id=$objp->rowid; $taskstatic->ref=$objp->ref; $taskstatic->label=$objp->label; @@ -183,24 +188,18 @@ class box_task extends ModeleBoxes $label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - $boxcontent.= getTaskProgressView($taskstatic, $label, true, false, true); + $boxcontent = getTaskProgressView($taskstatic, $label, true, false, true); + $this->info_box_contents[$i][] = array( + 'td' => '', + 'text' => $boxcontent, + ); $i++; } } else { dol_print_error($this->db); } } - - // set cookie by js - if(empty($i)){ - $boxcontent.=''; - } - - $this->info_box_contents[0][] = array( - 'td' => '', - 'text' => $boxcontent, - ); } /** diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index aafebd7b99f..5f8c630e46a 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1392,7 +1392,6 @@ class CMailFile $i=0; foreach ($matches[1] as $full) { - if (preg_match('/file=([A-Za-z0-9_\-\/]+[\.]?[A-Za-z0-9]+)?$/i', $full, $regs)) // If xxx is 'file=aaa' { $img = $regs[1]; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 60a5d9519a4..a02f00fbac9 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -112,7 +112,6 @@ class CSMSFile if (empty($conf->global->MAIN_DISABLE_ALL_SMS)) { - // Action according to choosed sending method if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c99f78c3483..ee5b97c502a 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1103,7 +1103,6 @@ abstract class CommonDocGenerator global $hookmanager; foreach ($this->cols as $colKey => $colDef) { - $parameters = array( 'colKey' => $colKey, 'pdf' => $pdf, diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b9a4479367e..9625d31fc77 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -885,7 +885,6 @@ abstract class CommonObject } if(!$already_added) { - $this->db->begin(); // Insert into database @@ -5984,7 +5983,6 @@ abstract class CommonObject $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; if (! empty($InfoFieldList[4])) { - // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); @@ -6440,7 +6438,6 @@ abstract class CommonObject $value = ''; // value was used, so now we reste it to use it to build final output $toprint=array(); while ( $obj = $this->db->fetch_object($resql) ) { - // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { @@ -6966,7 +6963,6 @@ abstract class CommonObject $viewfilename = $file; if ($size == 1 || $size == 'small') { // Format vignette - // Find name of thumb file $photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small')); if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; @@ -7406,7 +7402,7 @@ abstract class CommonObject if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref']=dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data - + $keys=array(); $values = array(); foreach ($fieldvalues as $k => $v) { @@ -7864,6 +7860,57 @@ abstract class CommonObject } } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $status New status to set (often a constant like self::STATUS_XXX) + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $triggercode Trigger code to use + * @return int <0 if KO, >0 if OK + */ + public function setStatusCommon($user, $status, $notrigger = 0, $triggercode = '') + { + $error=0; + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " SET status = ".$status; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + if (! $error) + { + $this->oldcopy= clone $this; + } + + if (! $error && ! $notrigger) { + // Call trigger + $result=$this->call_trigger($triggercode, $user); + if ($result < 0) $error++; + } + + if (!$error) { + $this->status = $status; + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** * Initialise object with example values * Id must be 0 if object instance is a specimen diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 287d8121213..72aa4bc4265 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -227,7 +227,7 @@ class Conf $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); foreach ($filesList as $file) { $file=dol_sanitizeFileName($file); - include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; // This file must set $this->global->XXX vars. + include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars. } } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index e03aa8c6992..ab1448bc412 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -369,7 +369,6 @@ class DiscountAbsolute } } elseif($this->fk_invoice_supplier_source) { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; $sql.=" set paye=0, fk_statut=1"; $sql.=" WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e465742cfef..f59aaab7bfa 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1404,7 +1404,6 @@ class ExtraFields $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; if (!empty($InfoFieldList[4])) { - // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$') !== false) { $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); @@ -1813,7 +1812,6 @@ class ExtraFields $value = ''; // value was used, so now we reste it to use it to build final output $toprint=array(); while ( $obj = $this->db->fetch_object($resql) ) { - // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d9442e43457..e6a6a077cf8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3913,7 +3913,6 @@ class Form if ($nbaccountfound > 0) print ''; print ''; } else { - $langs->load('banks'); if ($selected) { @@ -5323,7 +5322,7 @@ class Form * @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only * @param string $form_name Not used * @param int $d 1=Show days, month, years - * @param int $addnowlink Add a link "Now" + * @param int $addnowlink Add a link "Now", 1 with server time, 2 with local computer time * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. @@ -5605,12 +5604,32 @@ class Form { // Script which will be inserted in the onClick of the "Now" link $reset_scripts = ""; - + if ($addnowlink==2) // local computer time + { + // pad add leading 0 on numbers + $reset_scripts.="Number.prototype.pad = function(size) { + var s = String(this); + while (s.length < (size || 2)) {s = '0' + s;} + return s; + }; + var d = new Date();"; + } + // Generate the date part, depending on the use or not of the javascript calendar - $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m').'\');'; - $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y').'\');'; + if($addnowlink==1) // server time expressed in user time setup + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; + } + elseif($addnowlink==2) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(d.getMonth().pad());'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; + } /*if ($usecalendar == "eldy") { $base=DOL_URL_ROOT.'/core/'; @@ -5627,7 +5646,15 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; - $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');'; + if($addnowlink==1) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; + } + elseif($addnowlink==2) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; + } + if ($fullday) $reset_scripts .= ' } '; } // Update the minute part @@ -5635,7 +5662,14 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; - $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');'; + if($addnowlink==1) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; + } + elseif($addnowlink==2) + { + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; + } if ($fullday) $reset_scripts .= ' } '; } // If reset_scripts is not empty, print the link with the reset_scripts in the onClick diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 177f2f0cc61..42fec36ef6a 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -77,7 +77,6 @@ class FormCron extends Form $out.=''; } } else { - $out=''; + $out = ''; $out .= ''; $out .= ''; print '
' . $langs->trans("MailFile") . ''; // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript @@ -409,7 +410,8 @@ class FormTicket } // Other attributes - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $this->action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { print $ticketstat->showOptionals($extrafields, 'edit'); @@ -504,23 +506,18 @@ class FormTicket } print '>'; + $value = ' '; if ($format == 0) { $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); - } - - if ($format == 1) { + } elseif ($format == 1) { $value = $arraytypes['code']; - } - - if ($format == 2) { + } elseif ($format == 2) { $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); - } - - if ($format == 3) { + } elseif ($format == 3) { $value = $arraytypes['code']; } - print $value ? $value : ' '; + print $value; print ''; } } diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index a187e58cac1..4ff061933e9 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -128,7 +128,6 @@ class InfoBox if (! in_array($obj->box_id, $excludelist)) { - if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) { $boxname = preg_replace('/\.php$/i', '', $regs[1]); diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index a70605612fe..cdc5b283c44 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -135,7 +135,6 @@ class Link extends CommonObject { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorCompanyNameAlreadyExists", $this->name); $result=-1; } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index fd7b769096f..cb4e7ef9e5a 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -819,7 +819,6 @@ class Utils $tabfiles[] = array('name' => $mainlog, 'path' => $mainlogdir); foreach($tabfiles as $file) { - $logname = $file['name']; $logpath = $file['path']; diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index a20e033ab19..2230bfac5a1 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -276,7 +276,6 @@ function checkBanForAccount($account) } if ($country_code == 'BE') { // Belgium rules - } if ($country_code == 'ES') { // Spanish rules diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 513f63d5f06..caa0915b91a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -144,7 +144,6 @@ function getBrowserInfo($user_agent) $tablet = $detectmobile->isTablet(); if ($detectmobile->isMobile()) { - $phone = 'unknown'; // If phone/smartphone, we set phone os name. @@ -1893,7 +1892,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang /** - * Return an array with locale date info. + * Return an array with locale date info. * PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows * WARNING: This function always use PHP server timezone to return locale informations !!! * Usage must be avoid. @@ -2039,9 +2038,9 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ /** - * Return date for now. In most cases, we use this function without parameters (that means GMT time). + * Return date for now. In most cases, we use this function without parameters (that means GMT time). * - * @param string $mode 'gmt' => we return GMT timestamp, + * @param string $mode 'gmt' => we return GMT timestamp, * 'tzserver' => we add the PHP server timezone * 'tzref' => we add the company timezone * 'tzuser' => we add the user timezone @@ -2245,9 +2244,9 @@ function dol_print_socialnetworks($value, $cid, $socid, $type) if (! empty($type)) { - $htmllink ='
'; - $htmllink.=img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright'); - $htmllink.=$value; + $htmllink = '
'; + $htmllink .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); + $htmllink .= $value; if ($type == 'skype') { $htmllink.= ' '; @@ -2263,7 +2262,8 @@ function dol_print_socialnetworks($value, $cid, $socid, $type) } if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type=='skype') { - $addlink='AC_SKYPE'; $link=''; + $addlink='AC_SKYPE'; + $link=''; if (! empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link=''.img_object($langs->trans("AddAction"), "calendar").''; $htmllink.=($link?' '.$link:''); } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index c2c3528c869..6543b659a88 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1722,7 +1722,6 @@ function is_ip($ip) { // First we test if it is a valid IPv4 if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - // Then we test if it is a private range if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index dd8d1a4a944..5eb45b261a0 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -118,7 +118,6 @@ function _val($val) * escaping with a slash or encoding to UTF-8 where necessary */ for ($c = 0; $c < $strlen_var; ++$c) { - $ord_var_c = ord($val[$c]); switch (true) { diff --git a/htdocs/core/lib/ldap.lib.php b/htdocs/core/lib/ldap.lib.php index 3f1baa72e8a..01ebdd277e1 100644 --- a/htdocs/core/lib/ldap.lib.php +++ b/htdocs/core/lib/ldap.lib.php @@ -163,7 +163,6 @@ function show_ldap_content($result, $level, $count, $var, $hide = 0, $subcount = $hide=0; if (! is_numeric($key)) { - print '
'; print $key; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index fff750c167b..e6f36b25d47 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -123,7 +123,6 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = if (count($object->fields)) { - foreach($object->fields as $key => $val) { $i++; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d16fc569961..609201dd0c3 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -240,14 +240,18 @@ function pdf_getPDFFont($outputlangs) */ function pdf_getPDFFontSize($outputlangs) { + global $conf; + $size=10; // By default, for FPDI or ISO language on TCPDF - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) + if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower) { - if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF') + if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') { $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); } } + if (! empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE; + return $size; } @@ -2238,7 +2242,6 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = } else { - if (is_object($hookmanager)) { $special_code = $object->lines[$i]->special_code; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 9c6e7901d34..170421cecfd 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -98,7 +98,6 @@ function product_prepare_head($object) $h++; if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { - global $db; require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php index 4d1bc5b3593..988c7a2d78c 100644 --- a/htdocs/core/lib/stock.lib.php +++ b/htdocs/core/lib/stock.lib.php @@ -29,7 +29,7 @@ */ function stock_prepare_head($object) { - global $langs, $conf; + global $langs, $conf, $user; $h = 0; $head = array(); @@ -39,10 +39,13 @@ function stock_prepare_head($object) $head[$h][2] = 'card'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id; - $head[$h][1] = $langs->trans("StockMovements"); - $head[$h][2] = 'movements'; - $h++; + if (!empty($user->rights->stock->mouvement->lire)) + { + $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id; + $head[$h][1] = $langs->trans("StockMovements"); + $head[$h][2] = 'movements'; + $h++; + } /* $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$object->id; diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 543bdb025fa..5ff41f97495 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -786,7 +786,6 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no // Contact for this action if (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { - $contactList = ''; foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) { $contact = new Contact($db); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index be5871bf6e3..7beadc9496b 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -638,8 +638,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // TextTitleColor for title of Pages if ($foruserprofile) { - - } else { @@ -665,8 +663,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // BackgroundTableTitleColor if ($foruserprofile) { - - } else { @@ -692,8 +688,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // TextTitleColor if ($foruserprofile) { - - } else { @@ -719,7 +713,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // BackgroundTableLineOddColor if ($foruserprofile) { - } else { @@ -749,7 +742,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // BackgroundTableLineEvenColor if ($foruserprofile) { - } else { @@ -1005,7 +997,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - } print '
'; } diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 39e2150280e..5f27a68d63a 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -137,7 +137,7 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout } else { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred.png'; + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred_alpha.png'; } $title=$langs->trans("GoIntoSetupToChangeLogo"); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5d6bf501d82..380b6a22355 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -482,7 +482,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $mysoc->logo_squarred_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI); $logoContainerAdditionalClass = 'backgroundforcompanylogo'; - if(!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND)){ + if(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND)){ $logoContainerAdditionalClass = ''; } @@ -496,7 +496,8 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = }*/ else { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred.png'; + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo_squarred_alpha.png'; + $logoContainerAdditionalClass = ''; } $title=$langs->trans("GoIntoSetupToChangeLogo"); @@ -1172,7 +1173,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Fiscal year - Not really yet used. In a future will lock some periods. if ($conf->global->MAIN_FEATURES_LEVEL > 1) { - $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear', 20); + $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->fiscalyear->write, '', $mainmenu, 'fiscalyear', 20); } $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 30); @@ -1290,12 +1291,22 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Accounting $newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1); + // General Ledger $newmenu->add("/accountancy/bookkeeping/list.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("Bookkeeping"), 1, $user->rights->accounting->mouvements->lire); // Balance $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire); + // Closure + if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { + $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->rights->accounting->fiscalyear->write, '', $mainmenu, 'closure'); + + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_closure/', $leftmenu)) { + $newmenu->add("/accountancy/closure/validate.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->fiscalyear->write); + } + } + // Files if ((! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 1) || ! empty($conf->global->ACCOUNTANCY_SHOW_EXPORT_FILES_MENU)) { @@ -1305,9 +1316,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Reports $newmenu->add("/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->rights->accounting->comptarapport->lire); - $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire); + $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire); $newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire); } diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index be6bd9f095d..eed79c037fd 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -118,11 +118,11 @@ class mod_bom_advanced extends ModeleNumRefboms /** * Return next free value * - * @param Societe $objsoc Object thirdparty + * @param Product $objprod Object product * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - public function getNextValue($objsoc, $object) + public function getNextValue($objprod, $object) { global $db,$conf; @@ -139,7 +139,7 @@ class mod_bom_advanced extends ModeleNumRefboms $date = ($object->date_bom ? $object->date_bom : $object->date); - $numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', $objsoc, $date); + $numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', null, $date); return $numFinal; } diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index af7e173bbae..eefbc7570c0 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -108,16 +108,16 @@ class mod_bom_standard extends ModeleNumRefboms /** * Return next free value * - * @param Societe $objsoc Object thirdparty + * @param Product $objprod Object product * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - public function getNextValue($objsoc, $object) + public function getNextValue($objprod, $object) { global $db,$conf; // D'abord on recupere la valeur max - $posindice=8; + $posindice=9; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom"; $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; @@ -137,7 +137,7 @@ class mod_bom_standard extends ModeleNumRefboms } //$date=time(); - $date=$object->date; + $date=$object->date_creation; $yymm = strftime("%y%m", $date); if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index d2dd1f56218..badf7343295 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -269,7 +269,7 @@ class pdf_strato extends ModelePDFContract $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); - // Affiche notes + // Display notes if (! empty($object->note_public)) { $tab_top -= 2; @@ -411,7 +411,7 @@ class pdf_strato extends ModelePDFContract $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -613,7 +613,7 @@ class pdf_strato extends ModelePDFContract pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->CONTRACT_DRAFT_WATERMARK); } - //Prepare la suite + //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -727,7 +727,7 @@ class pdf_strato extends ModelePDFContract $this->recipient = $object->thirdparty; //Recipient name - // On peut utiliser le nom de la societe du contact + // You can use the name of the contact company if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 8d29edec7d8..21658ed32d0 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -146,7 +146,7 @@ class pdf_espadon extends ModelePdfExpedition /** * Function to build pdf onto disk * - * @param Object $object Object expedition to generate (or id if old method) + * @param Object $object Object expedition to generate (or id if old method) * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -218,7 +218,7 @@ class pdf_espadon extends ModelePdfExpedition if ($conf->expedition->dir_output) { - // Definition de $dir et $file + // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; @@ -370,7 +370,7 @@ class pdf_espadon extends ModelePdfExpedition // Notes if (! empty($object->note_public)) { - $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page + $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); } @@ -390,10 +390,10 @@ class pdf_espadon extends ModelePdfExpedition } - // Use new auto collum system + // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); - // Simulation de tableau pour connaitre la hauteur de la ligne de titre + // Table simulation to know the height of the title line $pdf->startTransaction(); $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); @@ -502,7 +502,7 @@ class pdf_espadon extends ModelePdfExpedition $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // weight @@ -606,10 +606,10 @@ class pdf_espadon extends ModelePdfExpedition $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - // Affiche zone totaux + // Display total area $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -653,12 +653,12 @@ class pdf_espadon extends ModelePdfExpedition /** * Show total to pay * - * @param PDF $pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle - * @param int $posy Position depart + * @param int $deja_regle Amount already paid + * @param int $posy Start Position * @param Translate $outputlangs Objet langs - * @return int Position pour suite + * @return int Position for suite */ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { @@ -673,7 +673,7 @@ class pdf_espadon extends ModelePdfExpedition $tab2_hl = 4; $pdf->SetFont('', 'B', $default_font_size - 1); - // Tableau total + // Total table $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format { @@ -824,7 +824,7 @@ class pdf_espadon extends ModelePdfExpedition pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); } - //Prepare la suite + //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1006,7 +1006,7 @@ class pdf_espadon extends ModelePdfExpedition } //Recipient name - // On peut utiliser le nom de la societe du contact + // You can use the name of the contact company if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index ad676dba22e..53f46ccc861 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -174,20 +174,20 @@ class pdf_merou extends ModelePdfExpedition $origin = $object->origin; - //Creation de l expediteur + //Create sender $this->expediteur = $mysoc; - //Creation du destinataire + //Create recipient $idcontact = $object->$origin->getIdContact('external', 'SHIPPING'); $this->destinataire = new Contact($this->db); if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); - //Creation du livreur + //Create deliverer $idcontact = $object->$origin->getIdContact('internal', 'LIVREUR'); $this->livreur = new User($this->db); if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); - // Definition de $dir et $file + // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; @@ -273,7 +273,7 @@ class pdf_merou extends ModelePdfExpedition $tab_height = $this->page_hauteur - $tab_top - $heightforfooter; $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter; - // Affiche notes + // Display notes if (! empty($object->note_public)) { $pdf->SetFont('', '', $default_font_size - 1); @@ -314,7 +314,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); - // Description de la ligne produit + // Description of product line $libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1); $nexY = $pdf->GetY(); @@ -335,7 +335,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->Rect(10+3, $curY, 3, 3); $pdf->Rect(20+3, $curY, 3, 3); - //Insertion de la reference du produit + //Inserting the product reference $pdf->SetXY(30, $curY); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0); @@ -404,7 +404,7 @@ class pdf_merou extends ModelePdfExpedition $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -579,11 +579,11 @@ class pdf_merou extends ModelePdfExpedition } //*********************Entete**************************** - //Nom du Document + //Document name $pdf->SetXY($Xoff, 7); $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Bordereau expedition + $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet //Num Expedition $Yoff = $Yoff+7; $Xoff = 142; @@ -601,7 +601,7 @@ class pdf_merou extends ModelePdfExpedition $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager); //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); - //Definition Emplacement du bloc Societe + //Definition Location of the Company block $Xoff = 110; $blSocX=90; $blSocY=24; @@ -632,7 +632,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } - // Date Expedition + // Date delivery $Yoff = $Yoff+7; $pdf->SetXY($blSocX-80, $blSocY+17); @@ -698,7 +698,7 @@ class pdf_merou extends ModelePdfExpedition } // Recipient name - // On peut utiliser le nom de la societe du contact + // You can use the name of the contact company if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 983c0c502ae..b180994b7e5 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -844,7 +844,6 @@ class pdf_rouget extends ModelePdfExpedition } if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); if (empty($hidetop)) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 1768a0b1950..4320c63f58b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -149,7 +149,7 @@ class pdf_crabe extends ModelePDFFactures $this->description = $langs->trans('PDFCrabeDescription'); $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template - // Dimensiont page + // Dimension page $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -359,7 +359,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - // Positionne $this->atleastonediscount si on a au moins une remise + // Set $this->atleastonediscount if you have at least one discount for ($i = 0 ; $i < $nblines ; $i++) { if ($object->lines[$i]->remise_percent) @@ -428,7 +428,7 @@ class pdf_crabe extends ModelePDFFactures } } - // Affiche notes + // Display notes $notetoshow=empty($object->note_public)?'':$object->note_public; if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { @@ -554,7 +554,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) @@ -606,7 +606,7 @@ class pdf_crabe extends ModelePDFFactures $sign=1; if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + // Collection of totals by value of VAT in $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress($object->id); if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation { @@ -712,19 +712,19 @@ class pdf_crabe extends ModelePDFFactures $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - // Affiche zone infos + // Display info area $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - // Affiche zone totaux + // Display total area $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); - // Affiche zone versements + // Display Payments area if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) { $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter); } - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -1046,7 +1046,7 @@ class pdf_crabe extends ModelePDFFactures // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { - // Si mode reglement non force ou si force a CHQ + // If unregulated or forced payment mode to CHQ if (! empty($conf->global->FACTURE_CHQ_NUMBER)) { $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); @@ -1137,7 +1137,7 @@ class pdf_crabe extends ModelePDFFactures $tab2_hl = 4; $pdf->SetFont('', '', $default_font_size - 1); - // Tableau total + // Total table $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 9e0fad32172..bf58ebb6e8e 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -574,7 +574,6 @@ class pdf_sponge extends ModelePDFFactures $pagenb = $pageposbeforeprintlines; for ($i = 0; $i < $nblines; $i++) { - $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); @@ -1268,7 +1267,6 @@ class pdf_sponge extends ModelePDFFactures $deja_paye = 0; $i = 1; if(!empty($TPreviousIncoice)){ - $pdf->setY($tab2_top); $posy = $pdf->GetY(); @@ -1276,7 +1274,6 @@ class pdf_sponge extends ModelePDFFactures foreach ($TPreviousIncoice as &$fac){ - if($posy > $this->page_hauteur - 4 ) { $this->_pagefoot($pdf, $object, $outputlangs, 1); $pdf->addPage(); @@ -1482,7 +1479,6 @@ class pdf_sponge extends ModelePDFFactures // VAT // Situations totals migth be wrong on huge amounts if ($object->situation_cycle_ref && $object->situation_counter > 1) { - $sum_pdf_tva = 0; foreach($this->tva as $tvakey => $tvaval){ $sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index a806cab111f..9997e68ca14 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -181,14 +181,6 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = ''; $r++; - $this->rights[$r][0] = 50430; - $this->rights[$r][1] = 'Define and close a fiscal year'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'fiscalyear'; - $this->rights[$r][5] = ''; - $r++; - $this->rights[$r][0] = 50401; $this->rights[$r][1] = 'Bind products and invoices with accounting accounts'; $this->rights[$r][2] = 'r'; @@ -197,16 +189,6 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = 'write'; $r++; - /* - $this->rights[$r][0] = 50402; - $this->rights[$r][1] = 'Make binding with products and invoices'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'ventilation'; - $this->rights[$r][5] = 'dispatch_advanced'; - $r++; - */ - $this->rights[$r][0] = 50411; $this->rights[$r][1] = 'Read operations in Ledger'; $this->rights[$r][2] = 'r'; @@ -255,6 +237,13 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = 'lire'; $r++; + $this->rights[$r][0] = 50430; + $this->rights[$r][1] = 'Manage fiscal periods, validate movements and close periods'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'fiscalyear'; + $this->rights[$r][5] = 'write'; + $r++; // Menus //------- diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index 488dccd9067..c5169c7f6d1 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -59,7 +59,7 @@ class modDataPolicy extends DolibarrModules { // It is used to group modules by family in module setup page $this->family = "technic"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '81'; + $this->module_position = '78'; // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); // Module label (no space allowed), used if translation string 'ModuledatapolicyName' not found (MyModue is name of module). diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 8286bca9c82..78832122ff0 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -45,7 +45,7 @@ class modDocumentGeneration extends DolibarrModules $this->numero = 1520; $this->family = "technic"; - $this->module_position = '80'; + $this->module_position = '78'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Direct mail document generation"; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index da2ac06dcea..a3e3e539468 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -85,6 +85,13 @@ class modProduct extends DolibarrModules $this->const[$r][3] = 'Module to control product codes'; $this->const[$r][4] = 0; $r++; + + $this->const[$r][0] = "PRODUCT_PRICE_UNIQ"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "1"; + $this->const[$r][3] = 'pricing rule by default'; + $this->const[$r][4] = 0; + $r++; /*$this->const[$r][0] = "PRODUCT_ADDON_PDF"; $this->const[$r][1] = "chaine"; diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php index ed628110044..fe8f43416f3 100644 --- a/htdocs/core/modules/modZapier.class.php +++ b/htdocs/core/modules/modZapier.class.php @@ -42,14 +42,14 @@ class modZapier extends DolibarrModules $this->db = $db; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 792000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + $this->numero = 50330; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'zapier'; // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = 100; + $this->module_position = '13'; // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); // Module label (no space allowed), used if translation string 'ModuleZapierName' not found (Zapier is name of module). diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index e70db46aefa..eeef6ab34e5 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -88,7 +88,6 @@ class printing_printgcp extends PrintingDriver 'type'=>'info', ); } else { - $this->google_id = $conf->global->OAUTH_GOOGLE_ID; $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; // Token storage diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index d8aed4f67cf..d3693932f76 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -756,8 +756,6 @@ class pdf_azur extends ModelePDFPropales if (count($filetomerge->lines) > 0) { foreach ($filetomerge->lines as $linefile) { if (! empty($linefile->id) && ! empty($linefile->file_name)) { - - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { if (! empty($conf->product->enabled)) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 3049214679e..0d4f86ca82a 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -867,8 +867,6 @@ class pdf_cyan extends ModelePDFPropales if (count($filetomerge->lines) > 0) { foreach ($filetomerge->lines as $linefile) { if (! empty($linefile->id) && ! empty($linefile->file_name)) { - - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { if (! empty($conf->product->enabled)) { diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index f8c0b06e514..3a8b1a78a3e 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -72,7 +72,6 @@ class pdf_squille extends ModelePdfReception $this->posxpuht=$this->page_largeur - $this->marge_droite; if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; @@ -658,7 +657,6 @@ class pdf_squille extends ModelePdfReception $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { - $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); @@ -754,7 +752,6 @@ class pdf_squille extends ModelePdfReception } if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); if (empty($hidetop)) { diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php index 8a7d3e9e58a..1c634023b80 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php @@ -107,7 +107,6 @@ class modGeneratePassStandard extends ModeleGenPassword // add random characters to $password until $length is reached while ($i < $this->length) { - // pick a random character from the possible ones $char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1); diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 2a5f797147e..71e4da43773 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -253,6 +253,7 @@ class pdf_stdmovement extends ModelePDFMovement $warehousestatic=new Entrepot($db); $movement=new MouvementStock($db); $userstatic=new User($db); + $element = 'movement'; $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; @@ -262,7 +263,9 @@ class pdf_stdmovement extends ModelePDFMovement $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields - foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); + if (! empty($extrafields->attributes[$element]['label'])) { + foreach ($extrafields->attributes[$element]['label'] as $key => $val) $sql.=($extrafields->attributes[$element]['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 @@ -335,7 +338,6 @@ class pdf_stdmovement extends ModelePDFMovement if ($conf->stock->dir_output) { - if ($resql) { $product = new Product($db); diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index ee050d44b21..b59ca8c2b22 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -236,7 +236,6 @@ print ''; } elseif (GETPOST('action') == 'confirm_delete' && GETPOST('confirm') == 'yes' && GETPOST('socid') > 0) { - // La suppression n'a pas été possible require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $societe = new Societe($this->db); $societe->fetch(GETPOST('socid')); // On vérifie si il est utilisé if ((in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $societe->typent_id == 8) && $societe->isObjectUsed(GETPOST('socid'))) { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; $form = new Form($this->db); echo $form->formconfirm($_SERVER["PHP_SELF"] . "?socid=" . GETPOST('socid'), substr($langs->trans("DATAPOLICIES_POPUP_ANONYME_TITLE"), 0, strlen($langs->trans("DATAPOLICIES_POPUP_ANONYME_TITLE")) - 2), $langs->trans("DATAPOLICIES_POPUP_ANONYME_TEXTE"), 'anonymiser', '', '', 1); @@ -428,7 +424,6 @@ class ActionsDatapolicy $societe->fetch(GETPOST('socid')); if (!in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) && $societe->typent_id != 8) { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; $jsscript .= ' '; - return $html; } diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 7827024d4fc..a1bf67cb8c5 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -201,7 +201,6 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 2d29542a948..8d1e04cafd2 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -91,7 +91,6 @@ print ''; $client = false; if ($socid > 0) { - $soc = new Societe($db); $soc->fetch($socid); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 33b7946355c..f63067d6af8 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -103,7 +103,6 @@ dol_fiche_head($head, 'productMargins', $titre, 0, $picto); print '
'; if ($id > 0) { - print ''; print '
'.$langs->trans('ChooseProduct/Service').''; print $form->select_produits($id, 'id', '', 20, 0, 1, 2, '', 1, array(), 0, 'All'); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 5cd32512713..4ac7fb6e716 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -295,7 +295,6 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) } else { - } } if ($dirins && $action == 'initsqlextrafields' && !empty($module)) @@ -537,6 +536,26 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', } else { + /** + * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ + /*public $fields=array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), @@ -562,14 +581,31 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', $i=10; while ($obj = $db->fetch_object($_results)) { + // fieldname $fieldname = $obj->Field; + // type $type = $obj->Type; if ($type == 'int(11)') $type='integer'; + // notnull $notnull = ($obj->Null == 'YES'?0:1); + // label $label = preg_replace('/_/', ' ', ucfirst($fieldname)); if ($fieldname == 'rowid') $label='ID'; + if ($fieldname == 'import_key') $label='ImportKey'; + // visible + $visible = -1; + if ($fieldname == 'entity') $visible = -2; + if ($fieldname == 'model_pdf') $visible = 0; + // enabled + $enabled = 1; + // default + $default = ''; + if ($fieldname == 'entity') $default=1; - $string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."', 'enabled'=>1, 'visible'=>-2"; + $string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."',"; + if ($default != '') $string.= " 'default'=>".$default.","; + $string.= " 'enabled'=>".$enabled.","; + $string.= " 'visible'=>".$visible; if ($notnull) $string.= ", 'notnull'=>".$notnull; if ($fieldname == 'ref') $string.= ", 'showoncombobox'=>1"; $string.= ", 'position'=>".$i."),\n"; @@ -1332,7 +1368,6 @@ else } else { - $message=info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); $allowfromweb=0; } @@ -1578,7 +1613,7 @@ elseif (! empty($module)) print '
'; print '
'; - print load_fiche_titre($langs->trans("DescriptorFile")); + print load_fiche_titre($langs->trans("DescriptorFile"), '', ''); if (! empty($moduleobj)) { @@ -1638,35 +1673,33 @@ elseif (! empty($module)) print ''; print ''; - - print '

'; - - // Readme file - print load_fiche_titre($langs->trans("ReadmeFile")); - - print '
'; - print '
'; - if (dol_is_file($dirread.'/'.$pathtofilereadme)) print $moduleobj->getDescLong(); - else print $langs->trans("ErrorFileNotFound", $pathtofilereadme); - - print '

'; - - // ChangeLog - print load_fiche_titre($langs->trans("ChangeLog")); - - print '
'; - print '
'; - - if (dol_is_file($dirread.'/'.$pathtochangelog)) print $moduleobj->getChangeLog(); - else print $langs->trans("ErrorFileNotFound", $pathtochangelog); - - print '
'; } else { print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; } + if (! empty($moduleobj)) + { + print '

'; + + // Readme file + print load_fiche_titre($langs->trans("ReadmeFile"), '', ''); + + print ''; + if (dol_is_file($dirread.'/'.$pathtofilereadme)) print '
'.$moduleobj->getDescLong().'
'; + else print ''.$langs->trans("ErrorFileNotFound", $pathtofilereadme).''; + + print '

'; + + // ChangeLog + print load_fiche_titre($langs->trans("ChangeLog"), '', ''); + + print ''; + if (dol_is_file($dirread.'/'.$pathtochangelog)) print '
'.$moduleobj->getChangeLog().'
'; + else print ''.$langs->trans("ErrorFileNotFound", $pathtochangelog).''; + } + dol_fiche_end(); } else @@ -2488,7 +2521,6 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - print ''; $htmlhelp=$langs->trans("PermissionsDefDescTooltip", ''.$langs->trans('DefaultPermissions').''); print $form->textwithpicto($langs->trans("PermissionsDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index fcf529db13b..530b320b111 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -205,7 +205,6 @@ class ActionsMyModule /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' { - } return $ret; @@ -234,7 +233,6 @@ class ActionsMyModule /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' { - } return $ret; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 371c4498da8..59da2cde8ae 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -489,6 +489,82 @@ class MyObject extends CommonObject return $this->deleteLineCommon($user, $idline, $notrigger); } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) + { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'BOM_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) + { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'BOM_CLOSE'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) + { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOM_REOPEN'); + } + /** * Return a link to the object card (with optionaly the picto) * @@ -722,7 +798,6 @@ class MyObject extends CommonObject $langs->load("mymodule@mymodule"); if (! dol_strlen($modele)) { - $modele = 'standard'; if ($this->modelpdf) { diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index 17d8d0cf150..db2c79ca082 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -103,7 +103,6 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Data and type of action are stored into $object and $action switch ($action) { - // Users //case 'USER_CREATE': //case 'USER_MODIFY': diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 01d800f23c8..5727d596a6d 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -114,8 +114,6 @@ $permissiontoadd=$user->rights->mymodule->write; // Used by the include of actio /* * Actions - * - * Put here all code to do according to value of "action" parameter */ $parameters=array(); @@ -129,7 +127,7 @@ if (empty($reshook)) $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); if (empty($backtopage)) { - if (empty($id)) $backtopage = $backurlforlist; + if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist; else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record @@ -437,6 +435,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send print '' . $langs->trans('SendMail') . ''."\n"; + // Back to draft + if (! empty($user->rights->mymodule->write) && $object->status == BOM::STATUS_VALIDATED) + { + print '' . $langs->trans("SetToDraft") . ''; + } + // Modify if (! empty($user->rights->mymodule->write)) { diff --git a/htdocs/mrp/ChangeLog.md b/htdocs/mrp/ChangeLog.md new file mode 100644 index 00000000000..416bad1d559 --- /dev/null +++ b/htdocs/mrp/ChangeLog.md @@ -0,0 +1,5 @@ +# CHANGELOG MRP FOR DOLIBARR ERP CRM + +## 1.0 +Initial version + diff --git a/htdocs/mrp/README.md b/htdocs/mrp/README.md new file mode 100644 index 00000000000..b23e31fb577 --- /dev/null +++ b/htdocs/mrp/README.md @@ -0,0 +1,3 @@ +# MRP Module + +Module to manage Manufacturing Orders (MO) \ No newline at end of file diff --git a/htdocs/mrp/admin/setup.php b/htdocs/mrp/admin/setup.php new file mode 100644 index 00000000000..8d7df29b383 --- /dev/null +++ b/htdocs/mrp/admin/setup.php @@ -0,0 +1,151 @@ + + * Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson + * + * 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 . + */ + +/** + * \file mrp/admin/setup.php + * \ingroup mrp + * \brief Mrp setup page. + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +global $langs, $user; + +// Libraries +require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once '../lib/mrp.lib.php'; +//require_once "../class/myclass.class.php"; + +// Translations +$langs->loadLangs(array("admin", "mrp")); + +// Access control +if (! $user->admin) accessforbidden(); + +// Parameters +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +$arrayofparameters=array( + 'MRP_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), + 'MRP_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +); + + + +/* + * Actions + */ + +if ((float) DOL_VERSION >= 6) +{ + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; +} + + + +/* + * View + */ + +$page_name = "MrpSetup"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mrp'); + +// Configuration header +$head = mrpAdminPrepareHead(); +dol_fiche_head($head, 'settings', '', -1, "mrp"); + +// Setup page goes here +echo ''.$langs->trans("MrpSetupPage").'

'; + + +if ($action == 'edit') +{ + print '
'; + print ''; + print ''; + + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); + print '
'; + + print '
'; + print ''; + print '
'; + + print '
'; + print '
'; +} +else +{ + if (! empty($arrayofparameters)) + { + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); + print '' . $conf->global->$key . '
'; + + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; + } + else + { + print '
'.$langs->trans("NothingToSetup"); + } +} + + +// Page end +dol_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php new file mode 100644 index 00000000000..5bac2320b24 --- /dev/null +++ b/htdocs/mrp/class/mo.class.php @@ -0,0 +1,745 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 . + */ + +/** + * \file class/mo.class.php + * \ingroup mrp + * \brief This file is a CRUD class file for Mo (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for Mo + */ +class Mo extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'mo'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'mrp_mo'; + + /** + * @var int Does mo support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does mo support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for mo. Must be the part after the 'object_' into object_mo.png + */ + public $picto = 'mrp'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; // To produce + const STATUS_INPROGRESS = 2; + const STATUS_DONE = 3; + const STATUS_CANCELED = -1; + + + + /** + * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>-1, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), + 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'index'=>1, 'comment'=>"Qty to produce",), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>62, 'notnull'=>-1,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,), + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',), + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), + 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'), + 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,), + 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'Done', '-1'=>'Canceled')), + ); + public $rowid; + public $ref; + public $entity; + public $label; + public $qty; + public $fk_soc; + public $note_public; + public $note_private; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $import_key; + public $status; + public $fk_product; + public $date_start_planned; + public $date_end_planned; + public $fk_bom; + public $fk_project; + // END MODULEBUILDER PROPERTIES + + + // If this object has a subtable with lines + + /** + * @var int Name of subtable line + */ + //public $table_element_line = 'mrp_moline'; + + /** + * @var int Field with ID of parent key if this field has a parent + */ + //public $fk_element = 'fk_mo'; + + /** + * @var int Name of subtable class that manage subtable lines + */ + //public $class_element_line = 'Moline'; + + /** + * @var array List of child tables. To test if we can delete object. + */ + //protected $childtables=array(); + + /** + * @var array List of child tables. To know object to delete on cascade. + */ + //protected $childtablesoncascade=array('mrp_modet'); + + /** + * @var MoLine[] Array of subtable lines + */ + //public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($val['arrayofkeyval'])) + { + foreach($val['arrayofkeyval'] as $key2 => $val2) + { + $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (! $error) + { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) + { + $error++; + } + } + + if (! $error) + { + // copy external contacts if same company + if (property_exists($this, 'socid') && $this->socid == $object->socid) + { + if ($this->copy_linked_contact($object, 'external') < 0) + $error++; + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLines() + { + $this->lines=array(); + + $result = $this->fetchLinesCommon(); + return $result; + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records=array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList(); + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + else $sql .= ' WHERE 1 = 1'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key=='t.rowid') { + $sqlwhere[] = $key . '='. $value; + } + elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } + elseif ($key=='customsql') { + $sqlwhere[] = $value; + } + else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < min($limit, $num)) + { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Delete a line of object in database + * + * @param User $user User that delete + * @param int $idline Id of line to delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int >0 if OK, <0 if KO + */ + public function deleteLine(User $user, $idline, $notrigger = false) + { + if ($this->status < 0) + { + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; + return -2; + } + + return $this->deleteLineCommon($user, $idline, $notrigger); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + + $label = '' . $langs->trans("Mo") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = dol_buildpath('/mrp/mo_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowMo"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action,$hookmanager; + $hookmanager->initHooks(array('modao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + + /** + * Return label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("mrp"); + $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + } + + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 4) + { + return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 6) + { + return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + } + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + /** + * Create an array of lines + * + * @return array|int array of lines if OK, <0 if KO + */ + public function getLinesArray() + { + $this->lines=array(); + + $objectline = new MoLine($this->db); + $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_mo = '.$this->id)); + + if (is_numeric($result)) + { + $this->error = $this->error; + $this->errors = $this->errors; + return $result; + } + else + { + $this->lines = $result; + return $this->lines; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf,$langs; + + $langs->load("mrp"); + + if (! dol_strlen($modele)) { + $modele = 'standard'; + + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->MO_ADDON_PDF)) { + $modele = $conf->global->MO_ADDON_PDF; + } + } + + $modelpath = "core/modules/mrp/doc/"; + + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + //public function doScheduledJob($param1, $param2, ...) + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error=''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} + +/** + * Class MoLine. You can also remove this and generate a CRUD class for lines objects. + */ +class MoLine +{ + // To complete with content of an object MoLine + // We should have a field rowid, fk_mo and position +} diff --git a/htdocs/mrp/core/modules/modMrp.class.php b/htdocs/mrp/core/modules/modMrp.class.php new file mode 100644 index 00000000000..7e57f70c6c8 --- /dev/null +++ b/htdocs/mrp/core/modules/modMrp.class.php @@ -0,0 +1,349 @@ + + * Copyright (C) 2018-2019 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson + * + * 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 . + */ + +/** + * \defgroup mrp Module Mrp + * \brief Mrp module descriptor. + * + * \file htdocs/mrp/core/modules/modMrp.class.php + * \ingroup mrp + * \brief Description and activation file for module Mrp + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + +/** + * Description and activation class for module Mrp + */ +class modMrp extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs,$conf; + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 660; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'mrp'; + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "products"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '62'; + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module). + $this->description = "MRPDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "Module to Manage Manufacturing Orders (MO)"; + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'dolibarr'; + // Url to the file with your last numberversion of this module + //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; + + // Key used in llx_const table to save module status enabled/disabled (where MRP is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='mrp'; + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 0, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 0, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + // '/mrp/css/mrp.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + // '/mrp/js/mrp.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' + 'hooks' => array( + // 'data' => array( + // 'hookcontext1', + // 'hookcontext2', + // ), + // 'entity' => '0', + ), + // Set this to 1 if features of module are opened to external users + 'moduleforexternal' => 0, + ); + // Data directories to create when module is enabled. + // Example: this->dirs = array("/mrp/temp","/mrp/subdir"); + $this->dirs = array("/mrp/temp"); + // Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@mrp"); + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->depends = array('modBom'); + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->langfiles = array("mrp"); + $this->phpmin = array(5,5); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(8,0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(1 => array('MRP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), + // 2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) + // ); + $this->const = array( + // 1 => array('MRP_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); + + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ + + if (! isset($conf->mrp) || ! isset($conf->mrp->enabled)) { + $conf->mrp=new stdClass(); + $conf->mrp->enabled=0; + } + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mrp:$user->rights->mrp->read:/mrp/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mrp:$user->rights->othermodule->read:/mrp/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + + // Dictionaries + $this->dictionaries=array(); + /* Example: + $this->dictionaries=array( + 'langs'=>'mylangfile@mrp', + // List of tables we want to see into dictonnary editor + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), + // Label of tables + 'tablib'=>array("Table1","Table2","Table3"), + // Request to select fields + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + // Sort order + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), + // List of fields (result of select to show dictionary) + 'tabfield'=>array("code,label","code,label","code,label"), + // List of fields (list of fields to edit a record) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), + // List of fields (list of fields for insert) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), + // Name of columns with primary key (try to always name it 'rowid') + 'tabrowid'=>array("rowid","rowid","rowid"), + // Condition to show each dictionary + 'tabcond'=>array($conf->mrp->enabled,$conf->mrp->enabled,$conf->mrp->enabled) + ); + */ + + // Boxes/Widgets + // Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget. + $this->boxes = array( + // 0 => array( + // 'file' => 'mrpwidget1.php@mrp', + // 'note' => 'Widget provided by Mrp', + // 'enabledbydefaulton' => 'Home', + // ), + // ... + ); + + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + // 0 => array( + // 'label' => 'MyJob label', + // 'jobtype' => 'method', + // 'class' => '/mrp/class/mo.class.php', + // 'objectname' => 'Mo', + // 'method' => 'doScheduledJob', + // 'parameters' => '', + // 'comment' => 'Comment', + // 'frequency' => 2, + // 'unitfrequency' => 3600, + // 'status' => 0, + // 'test' => '$conf->mrp->enabled', + // 'priority' => 50, + // ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50) + // ); + + // Permissions provided by this module + $this->rights = array(); + $r=0; + // Add here entries to declare new permissions + /* BEGIN MODULEBUILDER PERMISSIONS */ + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read objects of Mrp'; // Permission label + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update objects of Mrp'; // Permission label + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete objects of Mrp'; // Permission label + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $r++; + /* END MODULEBUILDER PERMISSIONS */ + + // Main menu entries to add + $this->menu = array(); + $r=0; + // Add here entries to declare new menus + /* BEGIN MODULEBUILDER TOPMENU */ + /* END MODULEBUILDER LEFTMENU MO */ + + // Exports profiles provided by this module + $r=1; + /* BEGIN MODULEBUILDER EXPORT MO */ + /* + $langs->load("mrp"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='mo@mrp'; + $keyforclass = 'Mo'; $keyforclassfile='/mymobule/class/mo.class.php'; $keyforelement='mo'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='mo'; $keyforaliasextra='extra'; $keyforelement='mo'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'mo as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')'; + $r++; */ + /* END MODULEBUILDER EXPORT MO */ + + // Imports profiles provided by this module + $r=1; + /* BEGIN MODULEBUILDER IMPORT MO */ + /* + $langs->load("mrp"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='mo@mrp'; + $keyforclass = 'Mo'; $keyforclassfile='/mymobule/class/mo.class.php'; $keyforelement='mo'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='mo'; $keyforaliasextra='extra'; $keyforelement='mo'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'mo as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')'; + $r++; */ + /* END MODULEBUILDER IMPORT MO */ + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $result=$this->_load_tables('/mrp/sql/'); + if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') + + // Create extrafields during init + //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + //$extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); + + $sql = array(); + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + return $this->_remove($sql, $options); + } +} diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index f5f723a8fac..b6c20cde620 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -175,7 +175,7 @@ print '
'; */ $max=5; -$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem"; +$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom as a"; $sql.= " WHERE a.entity IN (".getEntity('bom').")"; $sql.= $db->order("a.tms", "DESC"); @@ -200,6 +200,7 @@ if ($resql) $staticbom->id=$obj->rowid; $staticbom->ref=$obj->ref; $staticbom->date_modification=$obj->datem; + $staticbom->status=$obj->status; print ''; print ''.$staticbom->getNomUrl(1, 32).''; diff --git a/htdocs/mrp/lib/mrp.lib.php b/htdocs/mrp/lib/mrp.lib.php new file mode 100644 index 00000000000..7ee1fcd04c7 --- /dev/null +++ b/htdocs/mrp/lib/mrp.lib.php @@ -0,0 +1,54 @@ + + * + * 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 . + */ + +/** + * \file mrp/lib/mrp.lib.php + * \ingroup mrp + * \brief Library files with common functions for Mrp + */ + +/** + * Prepare admin pages header + * + * @return array + */ +function mrpAdminPrepareHead() +{ + global $langs, $conf; + + $langs->load("mrp"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/mrp/admin/setup.php", 1); + $head[$h][1] = $langs->trans("Settings"); + $head[$h][2] = 'settings'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@mrp:/mrp/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@mrp:/mrp/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'mrp'); + + return $head; +} diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php new file mode 100644 index 00000000000..6189761269e --- /dev/null +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -0,0 +1,83 @@ +. + */ + +/** + * \file lib/mrp_mo.lib.php + * \ingroup mrp + * \brief Library files with common functions for Mo + */ + +/** + * Prepare array of tabs for Mo + * + * @param Mo $object Mo + * @return array Array of tabs + */ +function moPrepareHead($object) +{ + global $db, $langs, $conf; + + $langs->load("mrp"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/mrp/mo_card.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) + { + $nbNote = 0; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = dol_buildpath('/mrp/mo_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + $head[$h][2] = 'note'; + $h++; + } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->mrp->dir_output . "/mo/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); + $head[$h][0] = dol_buildpath("/mrp/mo_document.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + $head[$h][2] = 'document'; + $h++; + + $head[$h][0] = dol_buildpath("/mrp/mo_agenda.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + $head[$h][2] = 'agenda'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@mrp:/mrp/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@mrp:/mrp/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'mo@mrp'); + + return $head; +} diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php new file mode 100644 index 00000000000..aab1ff10581 --- /dev/null +++ b/htdocs/mrp/mo_agenda.php @@ -0,0 +1,262 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 . + */ + +/** + * \file mo_agenda.php + * \ingroup mrp + * \brief Page of Mo events + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + + +// Load translation files required by the page +$langs->loadLangs(array("mrp","other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +if (GETPOST('actioncode', 'array')) +{ + $actioncode=GETPOST('actioncode', 'array', 3); + if (! count($actioncode)) $actioncode='0'; +} +else +{ + $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); +} +$search_agenda_label=GETPOST('search_agenda_label'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mrp', $id); + +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='a.datep,a.id'; +if (! $sortorder) $sortorder='DESC'; + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('moagenda','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity] . "/" . $object->id; + + + +/* + * Actions + */ + +$parameters=array('id'=>$socid); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Cancel + if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $actioncode=''; + $search_agenda_label=''; + } +} + + + +/* + * View + */ + +$contactstatic = new Contact($db); + +$form = new Form($db); + +if ($object->id > 0) +{ + $title=$langs->trans("Agenda"); + //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + $help_url = ''; + llxHeader('', $title, $help_url); + + if (! empty($conf->notification->enabled)) $langs->load("mails"); + $head = moPrepareHead($object); + + + dol_fiche_head($head, 'agenda', $langs->trans("Mo"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + + $object->info($object->id); + dol_print_object_info($object, 1); + + print '
'; + + dol_fiche_end(); + + + + // Actions buttons + + $objthirdparty=$object; + $objcon=new stdClass(); + + $out='&origin='.$object->element.'&originid='.$object->id; + $permok=$user->rights->agenda->myactions->create; + if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok) + { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; + } + + + print '
'; + + if (! empty($conf->agenda->enabled)) + { + if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } + } + + print '
'; + + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + { + $param='&id='.$object->id.'&socid='.$socid; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + + + //print load_fiche_titre($langs->trans("ActionsOnMo"), '', ''); + + // List of all actions + $filters=array(); + $filters['search_agenda_label']=$search_agenda_label; + + // TODO Replace this with same code than into list.php + //show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php new file mode 100644 index 00000000000..f15b45b96e5 --- /dev/null +++ b/htdocs/mrp/mo_card.php @@ -0,0 +1,550 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 . + */ + +/** + * \file mo_card.php + * \ingroup mrp + * \brief Page to create/edit/view mo + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies + + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'mocard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('mocard','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$isdraft = (($object->statut == Mo::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + +$permissionnote=$user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php +$permissionedit=$user->rights->mrp->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php + + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error=0; + + $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); + $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + if (empty($backtopage)) { + if (empty($id)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/mrp/mo_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $trigger_name='MO_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid='mo'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + * + * Put here all code to build page + */ + +$form=new Form($db); +$formfile=new FormFile($db); + +llxHeader('', $langs->trans('Mo'), ''); + +// Example : Adding jquery code +print ''; + + +// Part to create +if ($action == 'create') +{ + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Mo")), '', 'cubes'); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + dol_fiche_end(); + + print ' + + '; + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("Mo"), '', 'cubes'); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals(); + + $head = moPrepareHead($object); + dol_fiche_head($head, 'card', $langs->trans("Mo"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); + + + /* + * Lines + */ + + if (! empty($object->table_element_line)) + { + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + if (! empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print ''; + } + + if (! empty($object->lines)) + { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') + { + if ($action != 'editline') + { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, $soc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print '
'; + } + print '
'; + + print "
\n"; + } + + + // Buttons for actions + + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; + + // Modify + if (! empty($user->rights->mrp->write)) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + + // Clone + if (! empty($user->rights->mrp->write)) + { + print ''; + } + + /* + if ($user->rights->mrp->write) + { + if ($object->status == 1) + { + print ''.$langs->trans("Disable").''."\n"; + } + else + { + print ''.$langs->trans("Enable").''."\n"; + } + } + */ + + // Delete (need delete permission, or if draft, just need create/modify permission) + if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + // Documents + /*$objref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->mrp->dir_output . '/' . $objref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('mrp', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + */ + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'mo', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; + } + + //Select mail models is same action as presend + /* + if (GETPOST('modelselected')) $action = 'presend'; + + // Presend form + $modelmail='inventory'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->product->dir_output.'/inventory'; + $trackid = 'stockinv'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + */ +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php new file mode 100644 index 00000000000..09f34ae583e --- /dev/null +++ b/htdocs/mrp/mo_document.php @@ -0,0 +1,167 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 . + */ + +/** + * \file mo_document.php + * \ingroup mrp + * \brief Tab for documents linked to Mo + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp","companies","other","mails")); + + +$action=GETPOST('action', 'aZ09'); +$confirm=GETPOST('confirm'); +$id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$ref = GETPOST('ref', 'alpha'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mrp', $id); + +// Get parameters +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; +//if (! $sortfield) $sortfield="position_name"; + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('modocument','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity?$object->entity:$conf->entity] . "/mo/" . dol_sanitizeFileName($object->id); +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity?$object->entity:$conf->entity] . "/mo/" . dol_sanitizeFileName($object->ref); + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + + +/* + * View + */ + +$form = new Form($db); + +$title=$langs->trans("Mo").' - '.$langs->trans("Files"); +$help_url=''; +//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $title, $help_url); + +if ($object->id) +{ + /* + * Show tabs + */ + $head = moPrepareHead($object); + + dol_fiche_head($head, 'document', $langs->trans("Mo"), -1, $object->picto); + + + // Build file list + $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Number of files + print ''; + + // Total size + print ''; + + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + dol_fiche_end(); + + $modulepart = 'mrp'; + //$permission = $user->rights->mrp->create; + $permission = 1; + //$permtoedit = $user->rights->mrp->create; + $permtoedit = 1; + $param = '&id=' . $object->id; + + //$relativepathwithnofile='mo/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile='mo/' . dol_sanitizeFileName($object->ref).'/'; + + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + accessforbidden('', 0, 1); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php new file mode 100644 index 00000000000..2f32058a41f --- /dev/null +++ b/htdocs/mrp/mo_list.php @@ -0,0 +1,589 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 . + */ + +/** + * \file mo_list.php + * \ingroup mrp + * \brief List page for mo + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' + +// Load Dolibarr environment +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + +// load mrp libraries +require_once __DIR__ . '/class/mo.class.php'; + +// for other modules +//dol_include_once('/othermodule/class/otherobject.class.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp","other")); + +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'molist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id', 'int'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; + +// Initialize technical objects +$object = new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('molist')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (! $sortorder) $sortorder="ASC"; + +// Security check +if (empty($conf->mrp->enabled)) accessforbidden('Module not enabled'); +$socid=0; +if ($user->societe_id > 0) // Protection if external user +{ + //$socid = $user->societe_id; + accessforbidden(); +} +//$result = restrictedArea($user, 'mrp', $id, ''); + + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} + +// Definition of fields for list +$arrayfields=array(); +foreach($object->fields as $key => $val) +{ + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); +} +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='Mo'; + $objectlabel='Mo'; + $permtoread = $user->rights->mrp->read; + $permtodelete = $user->rights->mrp->delete; + $uploaddir = $conf->mrp->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + */ + +$form=new Form($db); + +$now=dol_now(); + +//$help_url="EN:Module_Mo|FR:Module_Mo_FR|ES:Módulo_Mo"; +$help_url=''; +$title = $langs->trans('ListOfManufacturingOrders'); + + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/', '', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql.=" WHERE 1 = 1"; +foreach($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +*/ + +$sql.=$db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { + $page = 0; + $offset = 0; + } +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/mrp/mo_card.php', 1).'?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +foreach($search as $key => $val) +{ + if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); + else $param.= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>$langs->trans("Validate"), + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), +); +if ($user->rights->mrp->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/mrp/mo_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->mrp->write); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cubes', 0, $newcardbutton, '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail="SendMoRef"; +$modelmail="mo"; +$objecttmp=new Mo($db); +$trackid='xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $cssforfield=(empty($val['css'])?'':$val['css']); + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $cssforfield=(empty($val['css'])?'':$val['css']); + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine=0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) + { + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (property_exists($obj, $key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + $cssforfield=(empty($val['css'])?'':$val['css']); + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; + + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + else print ''; + print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&', '&', $param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mrp->read; + $delallowed=$user->rights->mrp->write; + + print $formfile->showdocuments('massfilesarea_mrp', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php new file mode 100644 index 00000000000..a006f79a609 --- /dev/null +++ b/htdocs/mrp/mo_note.php @@ -0,0 +1,165 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 . + */ + +/** + * \file mo_note.php + * \ingroup mrp + * \brief Car with notes on Mo + */ + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; +if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; +if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; +if (! $res) die("Include of main fails"); + +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp","companies")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('monote','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mrp', $id); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity] . "/" . $object->id; + +$permissionnote=1; +//$permissionnote=$user->rights->mrp->creer; // Used by the include of actions_setnotes.inc.php + + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + + +/* + * View + */ + +$form = new Form($db); + +//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; +$help_url=''; +llxHeader('', $langs->trans('Mo'), $help_url); + +if ($id > 0 || ! empty($ref)) +{ + $object->fetch_thirdparty(); + + $head = moPrepareHead($object); + + dol_fiche_head($head, 'note', $langs->trans("Mo"), -1, $object->picto); + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + + + $cssclass="titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
'; + + dol_fiche_end(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/mrp/modulebuilder.txt b/htdocs/mrp/modulebuilder.txt new file mode 100644 index 00000000000..24ea0d6eac5 --- /dev/null +++ b/htdocs/mrp/modulebuilder.txt @@ -0,0 +1,3 @@ +# DO NOT DELETE THIS FILE MANUALLY +# File to flag module built using official module template. +# When this file is present into a module directory, you can edit it with the module builder tool. Use ModuleBuilder if you want to delete module. \ No newline at end of file diff --git a/htdocs/mrp/sql/llx_mrp_mo.key.sql b/htdocs/mrp/sql/llx_mrp_mo.key.sql new file mode 100644 index 00000000000..071a663dd56 --- /dev/null +++ b/htdocs/mrp/sql/llx_mrp_mo.key.sql @@ -0,0 +1,35 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 http://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_rowid (rowid); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_qty (qty); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_soc (fk_soc); +ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES user(rowid); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_status (status); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_product (fk_product); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_start_planned (date_start_planned); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_end_planned (date_end_planned); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_bom (fk_bom); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_project (fk_project); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_mrp_mo ADD UNIQUE INDEX uk_mrp_mo_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_field FOREIGN KEY (fk_field) REFERENCES llx_mrp_myotherobject(rowid); + diff --git a/htdocs/mrp/sql/llx_mrp_mo.sql b/htdocs/mrp/sql/llx_mrp_mo.sql new file mode 100644 index 00000000000..dbb8b0faa01 --- /dev/null +++ b/htdocs/mrp/sql/llx_mrp_mo.sql @@ -0,0 +1,39 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 http://www.gnu.org/licenses/. + + +CREATE TABLE llx_mrp_mo( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + entity integer DEFAULT 1 NOT NULL, + label varchar(255), + qty real NOT NULL, + fk_soc integer, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL, + fk_product integer NOT NULL, + date_start_planned datetime, + date_end_planned datetime, + fk_bom integer, + fk_project integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql b/htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql new file mode 100644 index 00000000000..5b280acc41f --- /dev/null +++ b/htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql @@ -0,0 +1,19 @@ +-- Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson +-- +-- 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 http://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_mrp_myobject_extrafields ADD INDEX idx_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/mrp/sql/llx_mrp_mo_extrafields.sql b/htdocs/mrp/sql/llx_mrp_mo_extrafields.sql new file mode 100644 index 00000000000..9245ac1c341 --- /dev/null +++ b/htdocs/mrp/sql/llx_mrp_mo_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson +-- +-- 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 http://www.gnu.org/licenses/. + +create table llx_mrp_myobject_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 1cdab974833..cdd8db1a0bd 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -171,7 +171,6 @@ if (empty($reshook)) } if ($action == 'edit') { - // Security check if (!$user->rights->opensurvey->write) accessforbidden(); } @@ -365,7 +364,6 @@ print ''."\n"; print '
'; if ($action != 'edit' && $user->rights->opensurvey->write) { - //Modify button print ''.$langs->trans("Modify") . ''; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 281c5188ecd..48c633126ce 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -381,7 +381,6 @@ class Opensurveysondage extends CommonObject if (! $error) { - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index ad31d99e645..017779b74f7 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -180,7 +180,6 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format = // Add column (with format date) if (isset($_POST["ajoutercolonne"]) && $object->format == "D") { - // Security check if (!$user->rights->opensurvey->write) accessforbidden(); @@ -189,7 +188,6 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") if (isset($_POST["nouveaujour"]) && $_POST["nouveaujour"] != "vide" && isset($_POST["nouveaumois"]) && $_POST["nouveaumois"] != "vide" && isset($_POST["nouvelleannee"]) && $_POST["nouvelleannee"] != "vide") { - $nouvelledate=dol_mktime(0, 0, 0, $_POST["nouveaumois"], $_POST["nouveaujour"], $_POST["nouvelleannee"]); if (isset($_POST["nouvelleheuredebut"]) && $_POST["nouvelleheuredebut"]!="vide"){ @@ -622,7 +620,6 @@ print ''."\n"; // loop to show the delete link if ($user->rights->opensurvey->write) { for ($i = 0; isset($toutsujet[$i]); $i++) { - print ''."\n"; } } diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index 58d9108708b..a8a1f8248d1 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -86,7 +86,6 @@ if (isset($_POST["confirmecreation"])) if ($testremplissage != "ok" || (!$toutchoix)) { setEventMessages($langs->trans("ErrorOpenSurveyOneChoice"), null, 'errors'); } else { - //format du sondage AUTRE $_SESSION["formatsondage"]="A"; diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index a05d428b695..3692f79048e 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -42,7 +42,6 @@ $erreur = false; // Insert survey if (GETPOST('confirmation')) { - // We save hours entered if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) { @@ -537,8 +536,8 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) //si on voit une erreur, le fond de la case est rouge if (isset($errheure[$i][$j]) && $errheure[$i][$j]) { print ''."\n"; - } else { //sinon la case est vide normalement - + } else { + //sinon la case est vide normalement print ''."\n"; } } diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index ae2ea6861c7..8c71ff0fcb7 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -341,7 +341,6 @@ if ($mode == 'userconf' && $user->admin) $sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; $resql = $db->query($sql); while ($row=$db->fetch_array($resql)) { - print ''; print ''.$row['login'].''; print ''.$row['module'].''; diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index f4105b040bb..299f78c1a7d 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -35,13 +35,11 @@ if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->e */ if ($_POST) { - $var_percent = GETPOST('var_percent', 'array'); $var_min_percent = GETPOST('var_min_percent', 'array'); $fk_level = GETPOST('fk_level', 'array'); for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { - $check = isset($var_min_percent[$i]); if ($i != 1) { @@ -70,7 +68,6 @@ if ($_POST) { } if (!$check1 || !$check2) { - //If the level is between range but percent fields are empty, then we ensure it does not exist in DB if ($check1) { $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_pricerules WHERE level = ".(int) $i); @@ -83,7 +80,6 @@ if ($_POST) { ".(int) $i.", ".$db->escape($i_fk_level).", ".$i_var_percent.", ".$i_var_min_percent.")"; if (!$db->query($sql)) { - //If we could not create, then we try updating $sql = "UPDATE ".MAIN_DB_PREFIX."product_pricerules SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".$i; diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 3f0a8e150d3..5fd289c5514 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -434,7 +434,6 @@ foreach ($dirmodels as $reldir) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) -16); diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 111992e4c81..4210a3a560a 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -292,7 +292,6 @@ if (empty($mysoc->country_code)) } else { - print '
'; print ''; print ''; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index a772e9c3c4f..4f6eea5b903 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -99,7 +99,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } // Multiprice - if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price + if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price // level (from 1 to 6) { $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; @@ -125,7 +125,6 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) // Price by customer if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index 9f8f44d9555..03e57a0c859 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -109,7 +109,6 @@ dol_fiche_head('');
global->PRODUIT_MULTIPRICES) { ?> - diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index 65351371a71..0b33d722837 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -81,7 +81,6 @@ dol_fiche_head('');
global->PRODUIT_MULTIPRICES) { ?> -
trans("SellingPrice"); ?>
diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 22a8af0d270..0af901b5abf 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1058,7 +1058,7 @@ else $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); print ''; - + // Net Measure print ''; - + // Brut Length if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { @@ -1438,7 +1438,7 @@ else $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); print $form->selectarray('finished', $statutarray, $object->finished); print ''; - + // Net Measure print ''; - + // Net Measure print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -if (! empty($extrafields->attributes[$object->table_element]['computed'])) { +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object @@ -448,16 +437,21 @@ while ($i < min($num, $limit)) print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; + $cssforfield=(empty($val['css'])?'':$val['css']); + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (! empty($arrayfields['t.'.$key]['checked'])) { - print ''; - print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; if (! $i) $totalarray['nbfield']++; if (! empty($val['isameasure'])) @@ -474,7 +468,7 @@ while ($i < min($num, $limit)) $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; if (! $i) $totalarray['nbfield']++; - print ''; + print ''."\n"; $i++; } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 4d6183ef39f..139fd681ee0 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -203,7 +203,6 @@ if (empty($reshook)) // Multiprices if (! $error && (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { - $newprice = GETPOST('price', 'array'); $newprice_min = GETPOST('price_min', 'array'); $newpricebase = GETPOST('multiprices_base_type', 'array'); @@ -336,7 +335,6 @@ if (empty($reshook)) $db->begin(); foreach ($pricestoupdate as $key => $val) { - $newprice = $val['price']; if ($val['price'] < $val['price_min'] && !empty($object->fk_price_expression)) { @@ -492,7 +490,6 @@ if (empty($reshook)) * **************************************************** */ if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { - $maxpricesupplier = $object->min_recommended_price(); $update_child_soc = GETPOST('updatechildprice', 'int'); diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 99980f879c8..de0e2512927 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -369,7 +369,6 @@ if ($resql) { if($nb_warehouse>1) { foreach($warehouses_list as &$wh) { - print ''; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 31af63242a1..94a379c4e90 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -391,7 +391,6 @@ else // Parent entrepot $e = new Entrepot($db); if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) { - print ''; @@ -429,30 +428,26 @@ else print ""; // Last movement - $sql = "SELECT max(m.datem) as datem"; - $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; - $sql .= " WHERE m.fk_entrepot = '".$object->id."'"; - $resqlbis = $db->query($sql); - if ($resqlbis) - { - $obj = $db->fetch_object($resqlbis); - $lastmovementdate=$db->jdate($obj->datem); + if (!empty($user->rights->stock->mouvement->lire)) { + $sql = "SELECT max(m.datem) as datem"; + $sql .= " FROM " . MAIN_DB_PREFIX . "stock_mouvement as m"; + $sql .= " WHERE m.fk_entrepot = '" . $object->id . "'"; + $resqlbis = $db->query($sql); + if ($resqlbis) { + $obj = $db->fetch_object($resqlbis); + $lastmovementdate = $db->jdate($obj->datem); + } else { + dol_print_error($db); + } + print '"; } - else - { - dol_print_error($db); - } - print '"; // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 824934992bf..57dd181bc91 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -95,6 +95,30 @@ class Entrepot extends CommonObject // List of short language codes for status public $statuts = array(); + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10), + 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-2, 'showoncombobox'=>1, 'position'=>25), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35), + 'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>-2, 'position'=>40), + 'fk_parent' =>array('type'=>'integer', 'label'=>'ParentWarehouse', 'enabled'=>1, 'visible'=>-2, 'position'=>41), + 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-2, 'position'=>45), + 'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-2, 'position'=>50), + 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-2, 'position'=>55), + 'fk_departement' =>array('type'=>'integer', 'label'=>'State', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'fk_pays' =>array('type'=>'integer', 'label'=>'Country', 'enabled'=>1, 'visible'=>-2, 'position'=>65), + //'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-2, 'position'=>82), + //'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>-2, 'position'=>84), + //'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportKey', 'enabled'=>1, 'visible'=>-2, 'position'=>85), + 'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-2, 'position'=>200), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + ); + + /** * Constructor * @@ -829,7 +853,6 @@ class Entrepot extends CommonObject $langs->load("stocks"); if (! dol_strlen($modele)) { - $modele = 'standard'; if ($this->modelpdf) { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 3a660a03d9a..2b92a759ffa 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -1108,7 +1108,6 @@ class MouvementStock extends CommonObject $langs->load("stocks"); if (! dol_strlen($modele)) { - $modele = 'stdmovement'; if ($this->modelpdf) { diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 97e1aadd087..a53b669c183 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -276,7 +276,6 @@ class ProductStockEntrepot extends CommonObject $resql = $this->db->query($sql); if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { $lines[$obj->rowid] = array( 'id'=>$obj->rowid diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index ae39ba63f3b..b38888be9bb 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -28,34 +28,50 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; // Load translation files required by the page -$langs->load("stocks"); +$langs->loadLangs(array("stocks","other")); -// Security check -$result=restrictedArea($user, 'stock'); +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'stocklist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $search_ref=GETPOST("sref", "alpha")?GETPOST("sref", "alpha"):GETPOST("search_ref", "alpha"); $search_label=GETPOST("snom", "alpha")?GETPOST("snom", "alpha"):GETPOST("search_label", "alpha"); $search_status=GETPOST("search_status", "int"); +// Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortfield = GETPOST("sortfield"); -$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortfield) $sortfield="e.ref"; if (! $sortorder) $sortorder="ASC"; -$page = GETPOST("page"); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page; + +// Security check +$result=restrictedArea($user, 'stock'); + $year = strftime("%Y", time()); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Entrepot($db); -$hookmanager->initHooks(array('stocklist')); $extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('stocklist')); -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); + $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -69,30 +85,69 @@ $fieldstosearchall = array( 'e.town'=>'Town', ); - -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +// Definition of fields for list +$arrayfields=array( + 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70), + 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71), + 'sellvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72), +); +foreach($object->fields as $key => $val) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $search_ref=""; - $sall=""; - $search_label=""; - $search_status=""; - $search_array_options=array(); + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_ref=""; + $sall=""; + $search_label=""; + $search_status=""; + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='Entrepot'; + $objectlabel='Warehouse'; + $permtoread = $user->rights->stock->lire; + $permtodelete = $user->rights->stock->supprimer; + $uploaddir = $conf->stock->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -103,6 +158,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $form=new Form($db); $warehouse=new Entrepot($db); +$now=dol_now(); + +$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$title = $langs->trans("ListOfWarehouses"); + + +// Build and execute select +// -------------------------------------------------------------------- $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; $sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; // Add fields from extrafields @@ -115,16 +178,16 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -//$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; +$sql=preg_replace('/,\s*$/', '', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; $sql.= " WHERE e.entity IN (".getEntity('stock').")"; if ($search_ref) $sql.= natural_search("e.ref", $search_ref); // ref if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -149,189 +212,308 @@ if ($result) } } $sql.= $db->order($sortfield, $sortorder); -$sql.= $db->plimit($limit+1, $offset); -$result = $db->query($sql); -if ($result) +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $num = $db->num_rows($result); - - $i = 0; - - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - llxHeader("", $langs->trans("ListOfWarehouses"), $help_url); - - $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=".urlencode($search_ref); - if ($search_label) $param.="&search_label=".urlencode($search_label); - if ($search_status) $param.="&search_status=".urlencode($search_status); - if ($sall) $param.="&sall=".urlencode($sall); - - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - - $newcardbutton=''; - if ($user->rights->stock->creer) + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { - $newcardbutton=''.$langs->trans('MenuNewWarehouse').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $page = 0; + $offset = 0; } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'generic', 0, $newcardbutton, '', $limit); - - if ($sall) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; - } - - $moreforfilter=''; - - print '
'; - print '
trans("SellingPrice"); ?>
'.$langs->trans("NetMeasure").''; print ''; @@ -1070,7 +1070,7 @@ else print ''; print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units')?GETPOST('weight_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2); print '
'.$langs->trans("NetMeasure").''; print ' '; @@ -1809,7 +1809,6 @@ else //Parent product. if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { - $combination = new ProductCombination($db); if ($combination->fetchByFkProductChild($object->id) > 0) { @@ -1852,7 +1851,7 @@ else print '
'.$langs->trans("Nature").''; print $object->getLibFinished(); print '
'.$langs->trans("NetMeasure").''; if ($object->net_measure != '') @@ -2035,17 +2034,17 @@ if ($action != 'create' && $action != 'edit') { if ($usercancreate) { - if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print ''; + if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) { if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { - print '
'.$langs->trans('ToClone').'
'."\n"; + print ''.$langs->trans('ToClone').''."\n"; } else { - print ''; + print 'id.'">'.$langs->trans("ToClone").''; } } } @@ -2057,21 +2056,21 @@ if ($action != 'create' && $action != 'edit') { if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { - print '
'.$langs->trans('Delete').'
'."\n"; + print ''.$langs->trans('Delete').''."\n"; } else { - print ''; + print 'id.'">'.$langs->trans("Delete").''; } } else { - print ''; + print ''.$langs->trans("Delete").''; } } else { - print ''; + print ''.$langs->trans("Delete").''; } } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 2a9f407bf54..81e2659d918 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -246,8 +246,13 @@ class Products extends DolibarrApi } $this->product->$field = $value; } + + $updatetype = false; + if ($this->product->type != $oldproduct->type && ($this->product->isProduct() || $this->product->isService())) { + $updatetype = true; + } - $result = $this->product->update($id, DolibarrApiAccess::$user, 1, 'update'); + $result = $this->product->update($id, DolibarrApiAccess::$user, 1, 'update', $updatetype); // If price mode is 1 price per product if ($result > 0 && ! empty($conf->global->PRODUCT_PRICE_UNIQ)) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1b46a656511..d7ab4e99c78 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -787,13 +787,14 @@ class Product extends CommonObject * Update a record into database. * If batch flag is set to on, we create records into llx_product_batch * - * @param int $id Id of product - * @param User $user Object user making update - * @param int $notrigger Disable triggers - * @param string $action Current action for hookmanager ('add' or 'update') - * @return int 1 if OK, -1 if ref already exists, -2 if other error + * @param int $id Id of product + * @param User $user Object user making update + * @param int $notrigger Disable triggers + * @param string $action Current action for hookmanager ('add' or 'update') + * @param boolean $updatetype Update product type + * @return int 1 if OK, -1 if ref already exists, -2 if other error */ - public function update($id, $user, $notrigger = false, $action = 'update') + public function update($id, $user, $notrigger = false, $action = 'update', $updatetype = false) { global $langs, $conf, $hookmanager; @@ -939,6 +940,11 @@ class Product extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."product"; $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; + + if ($updatetype && ($this->isProduct() || $this->isService())) { + $sql.= ", fk_product_type = " . $this->type; + } + $sql.= ", ref = '" . $this->db->escape($this->ref) ."'"; $sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); @@ -1045,7 +1051,6 @@ class Product extends CommonObject if (! $error) { if ($conf->variants->enabled) { - include_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; $comb = new ProductCombination($this->db); @@ -1175,7 +1180,6 @@ class Product extends CommonObject } if (!$error) { - include_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; include_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php'; @@ -5196,7 +5200,6 @@ class Product extends CommonObject ); for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { - $price = $baseprice; $price_min = $baseprice; diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index bfe50627e3d..54ceff8eb9d 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -212,7 +212,6 @@ class Productbatch extends CommonObject // TODO Check qty is ok for stock move. Negative may not be allowed. if ($this->qty < 0) { - } // Update request @@ -361,7 +360,6 @@ class Productbatch extends CommonObject if (! $error) { - } unset($object->context['createfromclone']); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index fecaa1c7ad7..8117d8fb6aa 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -393,12 +393,10 @@ class Productcustomerprice extends CommonObject dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); $num = $this->db->num_rows($resql); while ( $obj = $this->db->fetch_object($resql) ) { - $line = new PriceByCustomerLine(); $line->id = $obj->rowid; @@ -504,12 +502,10 @@ class Productcustomerprice extends CommonObject dol_syslog(get_class($this) . "::fetch_all_log", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); $num = $this->db->num_rows($resql); while ( $obj = $this->db->fetch_object($resql) ) { - $line = new PriceByCustomerLine(); $line->id = $obj->rowid; @@ -766,12 +762,10 @@ class Productcustomerprice extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); $num = $this->db->num_rows($resql); while ( ($obj = $this->db->fetch_object($resql)) && (empty($error)) ) { - // find if there is an existing line for the product and the subsidiaries $prodsocprice = new Productcustomerprice($this->db); @@ -784,12 +778,10 @@ class Productcustomerprice extends CommonObject $error ++; $this->error = $prodsocprice->error; } else { - // There is one line if (count($prodsocprice->lines) > 0) { // If force update => Update if (! empty($forceupdateaffiliate)) { - $prodsocpriceupd = new Productcustomerprice($this->db); $prodsocpriceupd->fetch($prodsocprice->lines [0]->id); @@ -927,7 +919,6 @@ class Productcustomerprice extends CommonObject } if (! $error) { - } unset($object->context['createfromclone']); diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index cbf71740497..6df66f7a140 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -259,7 +259,6 @@ class Propalmergepdfproduct extends CommonObject if ($this->db->num_rows($resql)) { while($obj = $this->db->fetch_object($resql)) { - $line = new PropalmergepdfproductLine(); $line->id = $obj->rowid; @@ -594,7 +593,6 @@ class Propalmergepdfproduct extends CommonObject if (! $error) { - } unset($object->context['createfromclone']); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 63d290b2387..f62ea66fd48 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -119,7 +119,6 @@ if ($action=='filemerge') { $is_refresh = GETPOST('refresh'); if (empty($is_refresh)) { - $filetomerge_file_array = GETPOST('filetoadd'); $filetomerge_file_array = GETPOST('filetoadd'); @@ -258,7 +257,6 @@ if ($object->id) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - $filearray = array_merge($filearray, dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1)); } @@ -282,7 +280,6 @@ if ($object->id) // Get language if ($conf->global->MAIN_MULTILANGS) { - $langs->load("languages"); print '
'; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index b81e989cbb9..59c81c83e29 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -21,6 +21,7 @@ * \brief List page for inventory */ +// Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -30,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; // Load translation files required by the page $langs->loadLangs(array("stocks","other")); -$action = GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation @@ -47,7 +48,7 @@ $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -67,7 +68,7 @@ if (! $sortorder) $sortorder="ASC"; // Security check $socid=0; -if ($user->societe_id > 0) +if ($user->societe_id > 0) // Protection if external user { //$socid = $user->societe_id; accessforbidden(); @@ -101,10 +102,10 @@ $arrayfields=array(); foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -119,8 +120,6 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); /* * Actions - * - * Put here all code to do according to value of "$action" parameter */ if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } @@ -164,8 +163,6 @@ if (empty($reshook)) /* * View - * - * Put here all code to render page */ $form=new Form($db); @@ -192,10 +189,10 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); +$sql=preg_replace('/,\s*$/', '', $sql); $sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('myobject').")"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) { @@ -218,11 +215,14 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); */ $sql.=$db->order($sortfield, $sortorder); @@ -231,18 +231,17 @@ $sql.=$db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { $page = 0; $offset = 0; } } -// if total resultset is smaller the limit, no need to do paging. +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $resql = $result; $num = $nbtotalofrecords; } else @@ -274,21 +273,6 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $title, $help_url); -// Example : Adding jquery code -print ''; - $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; @@ -296,7 +280,8 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); foreach($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); + else $param.= '&search_'.$key.'='.urlencode($search[$key]); } if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -308,7 +293,7 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); print ''; @@ -321,7 +306,9 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, '', '', $limit); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) $topicmail="Information"; @@ -330,7 +317,7 @@ $objecttmp=new Inventory($db); $trackid='inve'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) +if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; @@ -415,13 +402,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print '
'; + print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; @@ -484,7 +478,7 @@ while ($i < min($num, $limit)) print '
'; print empty($product->stock_warehouse[$wh['id']]->real) ? '0' : $product->stock_warehouse[$wh['id']]->real; print '
'.$langs->trans("ParentWarehouse").''; print $e->getNomUrl(3); print '
' . $langs->trans("LastMovement") . ''; + if ($lastmovementdate) { + print dol_print_date($lastmovementdate, 'dayhour') . ' '; + print '(' . $langs->trans("FullList") . ')'; + } else { + print $langs->trans("None"); + } + print "
'.$langs->trans("LastMovement").''; - if ($lastmovementdate) - { - print dol_print_date($lastmovementdate, 'dayhour').' '; - print '('.$langs->trans("FullList").')'; - } - else - { - print $langs->trans("None"); - } - print "
'."\n"; - - // Fields title search - print ''; - - print ''; - - print ''; - - print ''; - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - - print ''; - - print ''; - - print ''; - - print ''; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); - print "\n"; - - if ($num) - { - $warehouse=new Entrepot($db); - $var=false; - $totalarray=array(); - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($result); - - $warehouse->id = $obj->rowid; - $warehouse->ref = $obj->ref; - $warehouse->label = $obj->ref; - $warehouse->lieu = $obj->lieu; - $warehouse->fk_parent = $obj->fk_parent; - $warehouse->statut = $obj->statut; - - print ''; - print ''; - if (! $i) $totalarray['nbfield']++; - // Location - print ''; - if (! $i) $totalarray['nbfield']++; - - // Stock qty - print ''; - if (! $i) $totalarray['nbfield']++; - - // PMP value - print ''; - if (! $i) $totalarray['nbfield']++; - - // Selling value - print ''; - if (! $i) $totalarray['nbfield']++; - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - - // Status - print ''; - if (! $i) $totalarray['nbfield']++; - - print ''; - if (! $i) $totalarray['nbfield']++; - - print "\n"; - - - $i++; - } - - if ($totalnboflines-$offset <= $limit) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - } - - $db->free($result); - - print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); - print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
' . $warehouse->getNomUrl(1) . ''.$obj->lieu.''.price2num($obj->stockqty, 5).''; - if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); - else print ''; - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); - else - { - $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); - print $form->textwithtooltip($langs->trans("Variable"), $htmltext); - } - print ''.$warehouse->LibStatut($obj->statut, 5).'
'.$langs->trans("Total").''.price2num($totalStock, 5).''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); - else - { - $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); - print $form->textwithtooltip($langs->trans("Variable"), $htmltext); - } - print '
"; - print ""; - - print '
'; +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; } else { - dol_print_error($db); + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/product/stock/card.php?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($search_ref) $param.="&search_ref=".urlencode($search_ref); +if ($search_label) $param.="&search_label=".urlencode($search_label); +if ($search_status) $param.="&search_status=".urlencode($search_status); +if ($search_all) $param.="&search_all=".urlencode($search_all); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), +); +//if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton = dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->stock->creer); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail="Information"; +$modelmail="warehouse"; +$objecttmp=new Entrepot($db); +$trackid='ware'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; + $moreforfilter.= $langs->trans('MyFilter') . ': '; + $moreforfilter.= '
';*/ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; + +print ''; + +print ''; + +print ''; +print ''; +print ''; + +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +// Status +print ''; + +// Action column +print ''; +print ''."\n"; + +// Fields title label +// -------------------------------------------------------------------- +print ''; +print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +if ($num) +{ + $warehouse=new Entrepot($db); + + $totalarray=array(); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + $warehouse->id = $obj->rowid; + $warehouse->ref = $obj->ref; + $warehouse->label = $obj->ref; + $warehouse->lieu = $obj->lieu; + $warehouse->fk_parent = $obj->fk_parent; + $warehouse->statut = $obj->statut; + + // Show here line of result + print ''; + print ''; + if (! $i) $totalarray['nbfield']++; + // Location + print ''; + if (! $i) $totalarray['nbfield']++; + + // Stock qty + print ''; + if (! $i) $totalarray['nbfield']++; + + // PMP value + print ''; + if (! $i) $totalarray['nbfield']++; + + // Selling value + print ''; + if (! $i) $totalarray['nbfield']++; + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Status + print ''; + if (! $i) $totalarray['nbfield']++; + + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''."\n"; + + + $i++; + } + + if ($totalnboflines-$offset <= $limit) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } +} + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; +print ''; +print ''; +print ''; +print ''; +print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); +print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
' . $warehouse->getNomUrl(1) . ''.$obj->lieu.''.price2num($obj->stockqty, 5).''; + if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); + else print ''; + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); + else + { + $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); + print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + } + print ''.$warehouse->LibStatut($obj->statut, 5).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.$langs->trans("Total").''.price2num($totalStock, 5).''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); + else + { + $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); + print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + } + print '
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&', '&', $param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 08e48477264..24d2af3a358 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -125,11 +125,9 @@ if ($action == 'addline') // Warning, don't forget lines already added into the $_SESSION['massstockmove'] if ($producttmp->hasbatch()) { - } else { - } } diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 0278e1572e6..b04b8b8a220 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -451,7 +451,9 @@ $sql.= " m.type_mouvement,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 @@ -1048,7 +1050,7 @@ if ($resql) if (! empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code - print ''.'array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); +// Security check +if (!$user->rights->stock->mouvement->lire) { + accessforbidden(); +} /* @@ -429,7 +433,9 @@ $sql.= " m.fk_projet,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 328847c6473..dbcd0a2cf61 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -121,7 +121,6 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) { - $seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); @@ -136,7 +135,6 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) } if($maj_ok) { - $pse = new ProductStockEntrepot($db); if ($pse->fetch(0, $id, GETPOST('fk_entrepot', 'int')) > 0) { // Update @@ -159,7 +157,6 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) if($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) { - $pse = new ProductStockEntrepot($db); $pse->fetch(GETPOST('fk_productstockwarehouse', 'int')); @@ -466,7 +463,6 @@ if ($action == "transfert_stock" && ! $cancel) // Update batch information if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) { - $pdluo = new Productbatch($db); $result=$pdluo->fetch(GETPOST('pdluoid', 'int')); @@ -562,7 +558,6 @@ if ($id > 0 || $ref) print ''; if (! $variants) { - if ($conf->productbatch->enabled) { print ''; // Last movement - $sql = "SELECT max(m.datem) as datem"; - $sql .= " FROM " . MAIN_DB_PREFIX . "stock_mouvement as m"; - $sql .= " WHERE m.fk_product = '" . $object->id . "'"; - $resqlbis = $db->query($sql); - if ($resqlbis) { - $obj = $db->fetch_object($resqlbis); - $lastmovementdate = $db->jdate($obj->datem); - } else { - dol_print_error($db); + if (!empty($user->rights->stock->mouvement->lire)) + { + $sql = "SELECT max(m.datem) as datem"; + $sql .= " FROM " . MAIN_DB_PREFIX . "stock_mouvement as m"; + $sql .= " WHERE m.fk_product = '" . $object->id . "'"; + $resqlbis = $db->query($sql); + if ($resqlbis) { + $obj = $db->fetch_object($resqlbis); + $lastmovementdate = $db->jdate($obj->datem); + } else { + dol_print_error($db); + } + print '"; } - print '"; } print "
' . $langs->trans("ManageLotSerial") . ''; print $object->getLibStatut(0, 2); @@ -699,24 +694,27 @@ if ($id > 0 || $ref) print '
' . $langs->trans("LastMovement") . ''; + if ($lastmovementdate) { + print dol_print_date($lastmovementdate, 'dayhour') . ' '; + print '(' . $langs->trans("FullList") . ')'; + } else { + print '' . $langs->trans("None") . ''; + } + print "
' . $langs->trans("LastMovement") . ''; - if ($lastmovementdate) { - print dol_print_date($lastmovementdate, 'dayhour') . ' '; - print '(' . $langs->trans("FullList") . ')'; - } else { - print '' . $langs->trans("None") . ''; - } - print "
"; @@ -757,7 +755,6 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if (empty($action) && $object->id) { print "
\n"; diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 320f1aee9ec..ed4aea8c010 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -92,7 +92,6 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Action submit/delete file/link include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } @@ -111,7 +110,6 @@ llxHeader('', $langs->trans('ProductLot'), ''); if ($object->id) { - $head = productlot_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("Batch"), -1, 'barcode'); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 65453585e0f..eedde6dcb31 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -412,7 +412,6 @@ if ($resql) $obj = $db->fetch_object($resql); if ($obj) { - $productlot->id = $obj->rowid; $productlot->batch = $obj->batch; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 4c04ee6ee23..73d41e72196 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1166,19 +1166,18 @@ elseif ($object->id > 0) { if ($action != "edit" && $action != 'presend' ) { - // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a // "workflow" action so should appears somewhere else on // page. { - print ''; + print '' . $langs->trans("AddAction") . ''; }*/ // Send if ($object->statut != 2) { - print ''; + print '' . $langs->trans('SendMail').''; } // Modify @@ -1186,11 +1185,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans("Modify").''; } else { - print ''; + print ''.$langs->trans('Modify').''; } } @@ -1199,11 +1198,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans("Validate").''; } else { - print ''; + print ''.$langs->trans('Validate').''; } } @@ -1212,11 +1211,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans("Close").''; } else { - print ''; + print ''.$langs->trans('Close').''; } } @@ -1225,11 +1224,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans("ReOpen").''; } else { - print ''; + print ''.$langs->trans('ReOpen').''; } } @@ -1239,52 +1238,52 @@ elseif ($object->id > 0) if (! empty($conf->propal->enabled) && $user->rights->propal->creer) { $langs->load("propal"); - print ''; + print ''.$langs->trans("AddProp").''; } if (! empty($conf->commande->enabled) && $user->rights->commande->creer) { $langs->load("orders"); - print ''; + print ''.$langs->trans("CreateOrder").''; } if (! empty($conf->facture->enabled) && $user->rights->facture->creer) { $langs->load("bills"); - print ''; + print ''.$langs->trans("CreateBill").''; } if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) { $langs->load("supplier_proposal"); - print ''; + print ''.$langs->trans("AddSupplierProposal").''; } if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->creer) { $langs->load("suppliers"); - print ''; + print ''.$langs->trans("AddSupplierOrder").''; } if (! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->creer) { $langs->load("suppliers"); - print ''; + print ''.$langs->trans("AddSupplierInvoice").''; } if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) { $langs->load("interventions"); - print ''; + print ''.$langs->trans("AddIntervention").''; } if (! empty($conf->contrat->enabled) && $user->rights->contrat->creer) { $langs->load("contracts"); - print ''; + print ''.$langs->trans("AddContract").''; } if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) { $langs->load("trips"); - print ''; + print ''.$langs->trans("AddTrip").''; } if (! empty($conf->don->enabled) && $user->rights->don->creer) { $langs->load("donations"); - print ''; + print ''.$langs->trans("AddDonation").''; } } @@ -1293,11 +1292,11 @@ elseif ($object->id > 0) { if ($userWrite > 0) { - print ''; + print ''.$langs->trans('ToClone').''; } else { - print ''; + print ''.$langs->trans('ToClone').''; } } @@ -1306,11 +1305,11 @@ elseif ($object->id > 0) { if ($userDelete > 0 || ($object->statut == 0 && $user->rights->projet->creer)) { - print ''; + print ''.$langs->trans("Delete").''; } else { - print ''; + print ''.$langs->trans('Delete').''; } } } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e14cd53c3c3..da2d41512e1 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1671,7 +1671,6 @@ class Project extends CommonObject $langs->load("projects"); if (! dol_strlen($modele)) { - $modele = 'baleine'; if ($this->modelpdf) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 66bb8a23e45..e35b4b4bdad 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1938,7 +1938,6 @@ class Task extends CommonObject $langs->load("projects"); if (! dol_strlen($modele)) { - $modele = 'nodefault'; if ($this->modelpdf) { @@ -2062,7 +2061,6 @@ class Task extends CommonObject $resql=$this->db->query($sql); if ($resql) { - // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 87873054c29..3a2886229a0 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -523,7 +523,6 @@ $parameters=array('listofreferent'=>$listofreferent); $resHook = $hookmanager->executeHooks('completeListOfReferent', $parameters, $object, $action); if(!empty($hookmanager->resArray)) { - $listofreferent = array_merge($listofreferent, $hookmanager->resArray); } @@ -539,7 +538,6 @@ if ($action=="addelement") } elseif ($action == "unlink") { - $tablename = GETPOST("tablename", "aZ09"); $projectField = GETPOST("projectfield", "aZ09"); $elementselectid = GETPOST("elementselect", "int"); diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 6dba419c68f..8b718f1d898 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -260,7 +260,6 @@ $tasksarray=$task->getTasksArray(0, 0, ($object->id ? $object->id : $id), $socid if (count($tasksarray)>0) { - // Show Gant diagram from $taskarray using JSGantt $dateformat=$langs->trans("FormatDateShortJQuery"); // Used by include ganttchart.inc.php later diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 618170607bd..5c5cd398354 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -67,7 +67,6 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $dataseries[]=array($labelstatus, (isset($valsamount[$status])?(float) $valsamount[$status]:0)); if (! $conf->use_javascript_ajax) { - print ''; print ''.$labelstatus.''; print ''.price((isset($valsamount[$status])?(float) $valsamount[$status]:0), 0, '', 1, -1, -1, $conf->currency).''; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 27f41935910..734af5cb7ff 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -195,7 +195,6 @@ if ($resql) $var = true; while ($i < $num) { - $obj = $db->fetch_object($resql); print ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 59d727c5027..9a5514ff1cc 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -293,8 +293,10 @@ $sql.= ", s.rowid as socid, s.nom as name, s.email"; $sql.= ", cls.code as opp_status_code"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; -// Add fields for extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 00ef201aa9f..e13b7092b26 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -271,7 +271,9 @@ if (! empty($arrayfields['t.tobill']['checked']) || ! empty($arrayfields['t.bill $sql.=" , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 diff --git a/htdocs/public/donations/donateurs_code.php b/htdocs/public/donations/donateurs_code.php index 84a703b6690..a77300fc209 100644 --- a/htdocs/public/donations/donateurs_code.php +++ b/htdocs/public/donations/donateurs_code.php @@ -71,7 +71,6 @@ if ($resql) $num = $db->num_rows($resql); if ($num) { - print ""; print ''; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index c5317eba00f..6a0748f8f84 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -270,8 +270,6 @@ if ($action != 'dosign') { if ($found && ! $error) // We are in a management option and no error { - - } else { diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index ac926f12112..a548e849c7a 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -294,7 +294,6 @@ print ''."\n"; //The survey has expired, users can't vote or do any action if (!$canbemodified) { - print '

'.$langs->trans('SurveyExpiredInfo').'

'; llxFooterSurvey(); diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 5b4547650f7..f82e3549630 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1799,7 +1799,6 @@ print '
'; // Add more content on page for some services if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment mode { - // Stripe if (GETPOST('dopayment_stripe', 'alpha')) { diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 71729422ad2..f634d49ebac 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -156,7 +156,6 @@ if ($event->type == 'payout.created') { if ($result > 0) { - $subject = $societeName.' - [NOTIFICATION] Stripe payout scheduled'; if (!empty($user->email)) { $sendto = dolGetFirstLastname($user->firstname, $user->lastname) . " <".$user->email.">"; @@ -279,15 +278,12 @@ elseif ($event->type == 'payout.paid') { } } elseif ($event->type == 'customer.source.created') { - //TODO: save customer's source } elseif ($event->type == 'customer.source.updated') { - //TODO: update customer's source } elseif ($event->type == 'customer.source.delete') { - //TODO: delete customer's source } elseif ($event->type == 'customer.deleted') { diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 7d887b04fbf..c0ce22d69ed 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -344,7 +344,6 @@ if (! empty($usedolheader)) { llxFooter(); } else { ?> - diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 1af807aab7b..ce93ec020c3 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -78,7 +78,6 @@ if (GETPOST('addfile', 'alpha') && ! GETPOST('add', 'alpha')) { // Remove file if (GETPOST('removedfile', 'alpha') && !GETPOST('add', 'alpha')) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; // Set tmp directory diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 50b435fef26..9829aa03f7b 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -96,7 +96,6 @@ if ($action == "view_ticketlist") { $ret = $object->fetch('', '', $track_id); if ($ret && $object->id > 0) { - // vérifie si l'adresse email est bien dans les contacts du ticket $contacts = $object->liste_contact(-1, 'external'); foreach ($contacts as $contact) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index cba62da8cba..2c34cd55ee8 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -216,7 +216,6 @@ if (empty($reshook)) // Create reception if ($action == 'add' && $user->rights->reception->creer) { - $error = 0; $predef = ''; @@ -2041,7 +2040,6 @@ elseif ($id || $ref) $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if ($object->statut == Reception::STATUS_DRAFT && $num_prod > 0) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->creer)) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 3fee3376ebe..dd819adff0a 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -134,7 +134,6 @@ class Reception extends CommonObject $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/reception/"); // Load file with numbering class (if found) diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 65fdf153dd4..f90f1f73df1 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -156,7 +156,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' if (empty($reshook)) { if ($massaction == 'confirm_createbills') { - $receptions = GETPOST('toselect', 'array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $validate_invoices = GETPOST('validate_invoices', 'int'); @@ -395,7 +394,6 @@ if (empty($reshook)) } else { - $db->rollback(); $action='create'; $_GET["origin"]=$_POST["origin"]; @@ -427,7 +425,9 @@ $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= ' e.date_creation as date_creation, e.tms as date_update'; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index ab8659004bb..cbc1185aaab 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -97,7 +97,6 @@ $form = new Form($db); if ($id > 0 || ! empty($ref)) { - $head=reception_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans("Reception"), -1, 'sending'); diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index c61bd6453c4..00a92ecc115 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -140,7 +140,6 @@ class FormResource if ($outputmode != 2) { - $out.= '     '; $out.= ''; @@ -188,7 +187,6 @@ class FormResource { foreach($resourcestat->cache_code_type_resource as $id => $arraytypes) { - // We discard empty line if showempty is on because an empty line has already been output. if ($empty && empty($arraytypes['code'])) continue; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index cbc0202b042..a0c1a724ed8 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -315,7 +315,6 @@ else $act = fetchObjectByElement($element_id, $element, $element_ref); if (is_object($act)) { - $head=actions_prepare_head($act); dol_fiche_head($head, 'resources', $langs->trans("Action"), -1, 'action'); @@ -446,7 +445,6 @@ else { $socstatic = fetchObjectByElement($element_id, $element, $element_ref); if (is_object($socstatic)) { - $savobject = $object; $object = $socstatic; @@ -552,7 +550,6 @@ else if (is_object($product)) { - $head = product_prepare_head($product); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 50d384545c1..21ffa62bb8f 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -371,7 +371,6 @@ if ($action == 'create') if ($id) { - $head=salaries_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'payment'); diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 2c9a0d1349d..5aee0a83a29 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -434,7 +434,6 @@ class PaymentSalary extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); if ($this->id > 0) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 70d8279e0b3..92daac0fa9c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -786,7 +786,6 @@ if (empty($reshook)) // Update linked member if (! $error && $object->fk_soc > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; if (! $object->db->query($sql)) @@ -1310,10 +1309,16 @@ else print ''; } + // Phone / Fax + print ''; + print ''; + print ''; + print ''; + // Email / Web - print ''; + print ''; print ''; - print ''; + print ''; print ''; if (! empty($conf->socialnetworks->enabled)) { @@ -1367,12 +1372,6 @@ else // } // } - // Phone / Fax - print ''; - print ''; - print ''; - print ''; - // Prof ids $i=1; $j=0; while ($i <= 6) @@ -1956,11 +1955,17 @@ else print ''; } + // Phone / Fax + print ''; + print ''; + print ''; + print ''; + // EMail / Web - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { @@ -2004,12 +2009,6 @@ else // } // } - // Phone / Fax - print ''; - print ''; - print ''; - print ''; - // Prof ids $i=1; $j=0; while ($i <= 6) @@ -2471,7 +2470,6 @@ else print ''; if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) { - print ''; print ''; print ''; @@ -2709,19 +2707,19 @@ else if (! empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); - print ''; + print ''.$langs->trans('SendMail').''; } else { $langs->load("mails"); - print ''; + print ''.$langs->trans('SendMail').''; } if ($user->rights->societe->creer) { - print ''."\n"; + print ''.$langs->trans("Modify").''."\n"; } - + if (! empty($conf->adherent->enabled)) { $adh = new Adherent($db); @@ -2734,18 +2732,18 @@ else if ($user->rights->societe->supprimer) { - print ''; + print ''.$langs->trans('Merge').''; } if ($user->rights->societe->supprimer) { if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile { - print '
'.$langs->trans('Delete').'
'."\n"; + print ''.$langs->trans('Delete').''."\n"; } else { - print ''."\n"; + print ''.$langs->trans('Delete').''."\n"; } } } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ed3b26e04ac..8b95e85f899 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -117,6 +117,7 @@ class Thirdparties extends DolibarrApi * @param int $mode Set to 1 to show only customers * Set to 2 to show only prospects * Set to 3 to show only those are not customer neither prospect + * Set to 4 to show only suppliers * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.nom:like:'TheCompany%') and (t.date_creation:<:'20160101')" * @return array Array of thirdparty objects */ @@ -143,6 +144,7 @@ class Thirdparties extends DolibarrApi if ($mode == 1) $sql.= " AND t.client IN (1, 3)"; if ($mode == 2) $sql.= " AND t.client IN (2, 3)"; if ($mode == 3) $sql.= " AND t.client IN (0)"; + if ($mode == 4) $sql.= " AND t.fournisseur IN (1)"; $sql.= ' AND t.entity IN ('.getEntity('societe').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; @@ -1452,7 +1454,6 @@ class Thirdparties extends DolibarrApi throw new RestException(500, 'Error creating SocieteAccount entity.'); // We found an existing SocieteAccount entity, we are replacing it } else { - if(isset($request_data['site']) && $request_data['site'] !== $site) { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; $result = $db->query($sql); @@ -1515,7 +1516,6 @@ class Thirdparties extends DolibarrApi if($result->num_rows == 0 ){ throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist."); } else { - // If the user tries to edit the site member, we check first if if(isset($request_data['site']) && $request_data['site'] !== $site) { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 131c1c5d30a..45f11c5a4ce 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -174,8 +174,6 @@ class CompanyBankAccount extends Account $result = $this->db->query($sql); if ($result) { - - if (! $notrigger) { // Call trigger @@ -328,7 +326,6 @@ class CompanyBankAccount extends Account $rib = ''; if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) { - if ($this->label && $displayriblabel) { $rib = $this->label." : "; } diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 28b5ffc200c..85df9b4f069 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -531,7 +531,6 @@ if ($sql_select) else { if ($objp->fk_product > 0) { - echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, ''); // Show range @@ -543,7 +542,6 @@ if ($sql_select) print (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; } } else { - if (! empty($objp->label) || ! empty($objp->description)) { if ($type==1) $text = img_object($langs->trans('Service'), 'service'); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e29edb07717..7420c417aae 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -388,7 +388,9 @@ if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 19b11994114..6cb1b4abbbe 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -950,7 +950,6 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' try { $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus); if ($customerstripe->id) { - // When using the Charge API architecture if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { @@ -1387,7 +1386,6 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; foreach ($prodcustprice->lines as $line) { - print ''; $staticprod = new Product($db); $staticprod->fetch($line->fk_product); diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 1189b94923b..99abc1fd510 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -241,7 +241,6 @@ if (!$rowid) print "\n"; } } else { - } // End of page diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 894753f6440..45af7923fca 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -242,7 +242,6 @@ if (empty($reshook)) */ if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error=0; $datepaye = dol_now(); @@ -306,7 +305,6 @@ if (empty($reshook)) } elseif (preg_match('/src_/i', $source)) { - $customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); $src = $customer2->sources->retrieve("$source"); if ($src->type=='card') @@ -341,7 +339,6 @@ if (empty($reshook)) if (! $error) { - $paiement_id = $paiement->create($user, 0); if ($paiement_id < 0) { diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 5870427757a..70988b339b5 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -78,7 +78,6 @@ $stripeacc = $stripe->getStripeAccount($service); }*/ if (! $rowid) { - print ''; if ($optioncss != '') { print ''; diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 873adfc1cf7..6dc0a1e0815 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -78,7 +78,6 @@ $stripeacc = $stripe->getStripeAccount($service); }*/ if (! $rowid) { - print ''; if ($optioncss != '') print ''; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 736deacd0bb..3bbd8d8a33f 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -807,7 +807,6 @@ if (empty($reshook)) // Mise a jour d'une ligne dans la demande de prix elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('save') == $langs->trans("Save")) { - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); // Define info_bits @@ -865,7 +864,6 @@ if (empty($reshook)) // Check minimum price $productid = GETPOST('productid', 'int'); if (! empty($productid)) { - $productsupplier = new ProductFournisseur($db); if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 37a0541fd7a..bee290878c1 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2461,7 +2461,6 @@ class SupplierProposal extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/supplier_proposal/"); // Load file with numbering class (if found) @@ -2671,7 +2670,6 @@ class SupplierProposal extends CommonObject $langs->load("supplier_proposal"); if (! dol_strlen($modele)) { - $modele = 'aurore'; if ($this->modelpdf) { @@ -3102,7 +3100,6 @@ class SupplierProposalLine extends CommonObjectLine dol_syslog("SupplierProposalLine::delete", LOG_DEBUG); if ($this->db->query($sql) ) { - // Remove extrafields if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index f36013b289c..687d98911f2 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -250,7 +250,9 @@ $sql.= " p.rowid as project_id, p.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $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 : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index 179fa1deccb..dd369e233b9 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -71,7 +71,6 @@ if (! defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) $result=include_once $conffile; // Load conf file if ($result) { - if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility //Mysql driver support has been removed in favor of mysqli diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index a6b6dc6472a..b34889a3dce 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -163,7 +163,6 @@ if (! empty($conf->banque->enabled)) if (! empty($conf->stock->enabled)) { - print ''; // Force warehouse (this is not a default value) print ''; } -print $langs->trans('TotalTTC'); -print ' : '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; -print '
'.$sectionwithinvoicelink; -print ''; if ($_SESSION["basiclayout"]!=1) { print ''; @@ -595,16 +601,14 @@ if ($_SESSION["basiclayout"]==1) $htmlforlines = ''; foreach ($categories as $row){ $htmlforlines.= ''; + $htmlforlines.= '" onclick="LoadProducts(' . $row['id'] . ');">'; $htmlforlines.= ''; $htmlforlines.= ''."\n"; } $htmlforlines.= '
'.img_picto('', 'object_phoning').' '.$form->editfieldkey('Phone', 'phone', '', $object, 0).''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).'
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', $conf->global->SOCIETE_EMAIL_MANDATORY).'
'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', $conf->global->SOCIETE_EMAIL_MANDATORY).'
'.$form->editfieldkey('Web', 'url', '', $object, 0).'
'.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', '', $object, 0).'
'.$form->editfieldkey('Phone', 'phone', '', $object, 0).''.$form->editfieldkey('Fax', 'fax', '', $object, 0).'
'.img_picto('', 'object_phoning').' '.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'
'.$form->editfieldkey('Web', 'url', '', $object, 0).'
'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'
'.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).'
'.$form->editfieldkey('Phone', 'phone', '', $object, 0).''.$form->editfieldkey('Fax', 'fax', '', $object, 0).'
'; $string=''; foreach ($rib->getFieldsToShow() as $val) { - if ($val == 'BankCode') { $string .= $rib->code_banque.' '; } elseif ($val == 'BankAccountNumber') { @@ -1627,7 +1625,6 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) // Show fields of bank account foreach ($companybankaccount->getFieldsToShow(1) as $val) { - $require=false; if ($val == 'BankCode') { $name = 'code_banque'; @@ -1782,7 +1779,6 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) // Show fields of bank account foreach ($companybankaccount->getFieldsToShow(1) as $val) { - $require=false; if ($val == 'BankCode') { $name = 'code_banque'; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 931ccd7ab60..967f91ca39d 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -73,7 +73,6 @@ if (empty($reshook)) } if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { - $update_child_soc = GETPOST('updatechildprice'); // add price by customer @@ -146,7 +145,6 @@ if (empty($reshook)) } if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { - $prodcustprice->fetch(GETPOST('lineid', 'int')); $update_child_soc = GETPOST('updatechildprice'); @@ -228,7 +226,6 @@ dol_fiche_end(); if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - $prodcustprice = new Productcustomerprice($db); $sortfield = GETPOST("sortfield", 'alpha'); @@ -254,7 +251,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { } if ($action == 'add_customer_price') { - // Create mode print load_fiche_titre($langs->trans('PriceByCustomer')); @@ -327,7 +323,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print '
'; } elseif ($action == 'edit_customer_price') { - // Edit mode print load_fiche_titre($langs->trans('PriceByCustomer')); @@ -407,7 +402,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print '
'; } elseif ($action == 'showlog_customer_price') { - print ''."\n"; $filter = array ( @@ -431,7 +425,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVER ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords); if (count($prodcustprice->lines) > 0) { - print '
'; print ''; @@ -451,7 +444,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print '
'.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { diff --git a/htdocs/takepos/css/phone.css b/htdocs/takepos/css/phone.css new file mode 100644 index 00000000000..49d833ade17 --- /dev/null +++ b/htdocs/takepos/css/phone.css @@ -0,0 +1,81 @@ +html,body { + box-sizing: border-box; + padding:3px; + margin:0; + height:100%; + width:100%; +} + +.container{ + width: 100%; + height: 100%; + margin: 0 auto; + overflow: visible; + box-sizing: border-box; +} + +.phonerow1{ + margin: 0 auto; + width: 100%; + height: 40%; + min-height: 40%; +} + +.phonerow2{ + margin: 0 auto; + width: 100%; + height: 40%; +} + +.phonebuttonsrow{ + margin: 0 auto; + width: 100%; + height: 5%; +} + +.phonediv1{ + height:100%; + min-height: 100%; + width: 100%; + text-align: center; + box-sizing: border-box; + overflow: auto; + padding-top: 0; + padding-bottom: 10px; + padding-right: 5px; + padding-left: 5px; +} + +.phonediv2{ + height: 100%; + width: 100%; + box-sizing: border-box; + padding-top: 0; + padding-bottom: 10px; + padding-right: 5px; + padding-left: 5px; +} + +.phonediv3{ + height: 100%; + width: 100%; + box-sizing: border-box; + padding-top: 0; + padding-bottom: 10px; + padding-right: 5px; + padding-left: 5px; +} + +button.phonebutton { + display: inline-block; + position: relative; + padding: 0; + line-height: normal; + cursor: pointer; + vertical-align: middle; + text-align: center; + overflow: visible; /* removes extra width in IE */ + width:24%; + height:90%; + font-weight: bold; +} diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 1511d3520a1..a2c92aa13e4 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -570,13 +570,19 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) $label = $obj->label; $floor = $obj->floor; } - print $langs->trans('Place')." ".$label." - "; - print $langs->trans('Floor')." ".$floor." - "; + // In phone version only show when is invoice page + if ($mobilepage=="invoice" || $mobilepage=="") { + print $langs->trans('Place') . " " . $label . " - "; + print $langs->trans('Floor') . " " . $floor . " - "; + } +} +// In phone version only show when is invoice page +if ($mobilepage=="invoice" || $mobilepage=="") { + print $langs->trans('TotalTTC'); + print ' : ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ''; + print '
' . $sectionwithinvoicelink; + print '
' . $langs->trans('ReductionShort') . '
'; $htmlforlines.= $row['label']; $htmlforlines.= '
'; - $htmlforlines.= '
'; - $htmlforlines.= ''.$langs->trans("Floors").''; - $htmlforlines.= '
'; + $htmlforlines.= ''; print $htmlforlines; } @@ -618,17 +622,13 @@ if ($_SESSION["basiclayout"]==1) $htmlforlines = ''; foreach ($prods as $row) { $htmlforlines.= ''; + $htmlforlines.= '" onclick="AddProduct(\'' . $place . '\', ' . $row->id . ')">'; $htmlforlines.= ''; $htmlforlines.= $row->label; $htmlforlines.= ''; $htmlforlines.= ''."\n"; } $htmlforlines.= ''; - $htmlforlines.= '
'; - $htmlforlines.= ''.$langs->trans("Categories").''; - $htmlforlines.= ''.$langs->trans("Floors").''; - $htmlforlines.= '
'; print $htmlforlines; } @@ -641,24 +641,22 @@ if ($_SESSION["basiclayout"]==1) while($row = $db->fetch_array($resql)){ $rows[] = $row; $htmlforlines.= ''; + $htmlforlines.= '" onclick="LoadPlace(\'' . $row['label'] . '\')">'; $htmlforlines.= ''; $htmlforlines.= $row['label']; $htmlforlines.= ''; $htmlforlines.= ''."\n"; } $htmlforlines.= ''; - $htmlforlines.= '
'; - $htmlforlines.= ''.$langs->trans("Categories").''; - $htmlforlines.= ''.$langs->trans("Floors").''; - $htmlforlines.= '
'; print $htmlforlines; } } if ($placeid > 0) { - if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice") return; + //In Phone basic layout hide some content depends situation + if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice" && $action!="order") return; + if (is_array($invoice->lines) && count($invoice->lines)) { $tmplines = array_reverse($invoice->lines); @@ -716,14 +714,6 @@ else { // No invoice generated yet print ''; -if ($_SESSION["basiclayout"]==1 && $mobilepage=="invoice") -{ - print ''; -} - if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) { $soc = new Societe($db); diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php new file mode 100644 index 00000000000..2bd21626f34 --- /dev/null +++ b/htdocs/takepos/phone.php @@ -0,0 +1,190 @@ + + * + * 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 . + */ + +/** + * \file htdocs/takepos/phone.php + * \ingroup takepos + * \brief TakePOS Phone screen + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + +require '../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$action = GETPOST('action', 'alpha'); +$setterminal = GETPOST('setterminal', 'int'); + +if ($setterminal>0) +{ + $_SESSION["takeposterminal"]=$setterminal; +} + +$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter")); + +/* + * View + */ + +// Title +$title='TakePOS - Dolibarr '.DOL_VERSION; +if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; +$head=' + + +'; +top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + +?> + + + + +global->TAKEPOS_NUM_TERMINALS!="1" && $_SESSION["takeposterminal"]=="") print '
'.$langs->trans('TerminalSelect').'
'; +?> +
+
+ + + + +
+
+
+
+
+
+
+
+ +close(); diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index c49479c7ce1..37258da056c 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -63,7 +63,7 @@ if ($conf->browser->layout == 'phone') if ($_SESSION["takeposterminal"]!="" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT==1) { $_SESSION["basiclayout"]=1; - header("Location: invoice.php?mobilepage=invoice"); + header("Location: phone.php?mobilepage=invoice"); exit; } } @@ -407,7 +407,7 @@ function Refresh() { function New() { // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined console.log("New with place = , js place="+place); - var r = confirm(' 0 ? $langs->trans("ConfirmDeletionOfThisPOSSale") : $langs->trans("ConfirmDiscardOfThisPOSSale")); ?>'); + var r = confirm(' 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>'); if (r == true) { $("#poslines").load("invoice.php?action=delete&place="+place, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); diff --git a/htdocs/theme/dolibarr_logo_squarred_alpha.png b/htdocs/theme/dolibarr_logo_squarred_alpha.png new file mode 100644 index 00000000000..06e69ad8b7b Binary files /dev/null and b/htdocs/theme/dolibarr_logo_squarred_alpha.png differ diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index a3a952925e3..a9b1a6708a3 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -11,7 +11,8 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> div.divButAction { margin-bottom: 1.4em; } -div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused { +div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused, div.tabsAction > a.butActionDelete, +div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tabsAction > span.butActionDelete { margin-bottom: 1.4em !important; } div.tabsActionNoBottom > a.butAction, div.tabsActionNoBottom > a.butActionRefused { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e84b04b91d3..d93118b0b46 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3481,7 +3481,7 @@ div.info { padding-left: 10px; padding-right: 4px; padding-bottom: 8px; - margin: 0.5em 0em 0.5em 0em; + margin: 1em 0em 1em 0em; background: #eff8fc; } @@ -3492,7 +3492,7 @@ div.warning { padding-left: 10px; padding-right: 4px; padding-bottom: 8px; - margin: 0.5em 0em 0.5em 0em; + margin: 1em 0em 1em 0em; background: #fcf8e3; } div.warning a, div.info a, div.error a { @@ -3506,7 +3506,7 @@ div.error { padding-left: 10px; padding-right: 4px; padding-bottom: 8px; - margin: 0.5em 0em 0.5em 0em; + margin: 1em 0em 1em 0em; background: #EFCFCF; } diff --git a/htdocs/theme/eldy/main_menu_fa_icons.inc.php b/htdocs/theme/eldy/main_menu_fa_icons.inc.php index 0779de0142a..aec7b726da9 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.inc.php +++ b/htdocs/theme/eldy/main_menu_fa_icons.inc.php @@ -64,7 +64,6 @@ div.mainmenu.cashdesk .tmenuimage { } - div.mainmenu.cashdesk::before { content: "\f788"; } diff --git a/htdocs/theme/md/badges.inc.php b/htdocs/theme/md/badges.inc.php index 390348e2919..ac6eb9de53c 100644 --- a/htdocs/theme/md/badges.inc.php +++ b/htdocs/theme/md/badges.inc.php @@ -165,7 +165,6 @@ a.badge-dark:focus, a.badge-dark:hover { /* Default Status */ a.butAction, div.tabsAction > a.butActionRefused { +div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused, div.tabsAction > a.butActionDelete, +div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tabsAction > span.butActionDelete { margin-bottom: 1.4em !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9aec13e5fc7..097f6e1e5c6 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -108,12 +108,12 @@ if (! isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTL // Case of option editable only if option THEME_ELDY_ENABLE_PERSONALIZED is on if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) { - // 90A4AE, 607D8B, 455A64, 37474F - $conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card - $conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234'; - $conf->global->THEME_ELDY_TEXT='0,0,0'; - $conf->global->THEME_ELDY_FONT_SIZE1='14'; - $conf->global->THEME_ELDY_FONT_SIZE2='11'; + // 90A4AE, 607D8B, 455A64, 37474F + $conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card + $conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234'; + $conf->global->THEME_ELDY_TEXT='0,0,0'; + $conf->global->THEME_ELDY_FONT_SIZE1='14'; + $conf->global->THEME_ELDY_FONT_SIZE2='11'; } // Case of option availables only if THEME_ELDY_ENABLE_PERSONALIZED is on @@ -141,8 +141,8 @@ $colorbacklinepairhover=((! isset($conf->global->THEME_ELDY_USE_HOVER) || (strin $colorbacklinepairchecked=((! isset($conf->global->THEME_ELDY_USE_CHECKED) || (string) $conf->global->THEME_ELDY_USE_CHECKED === '255,255,255')?'':($conf->global->THEME_ELDY_USE_CHECKED === '1'?'edf4fb':$conf->global->THEME_ELDY_USE_CHECKED)); if (! empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)) { - $colorbacklinepairhover=((! isset($user->conf->THEME_ELDY_USE_HOVER) || $user->conf->THEME_ELDY_USE_HOVER === '255,255,255')?'':($user->conf->THEME_ELDY_USE_HOVER === '1'?'edf4fb':$user->conf->THEME_ELDY_USE_HOVER)); - $colorbacklinepairchecked=((! isset($user->conf->THEME_ELDY_USE_CHECKED) || $user->conf->THEME_ELDY_USE_CHECKED === '255,255,255')?'':($user->conf->THEME_ELDY_USE_CHECKED === '1'?'edf4fb':$user->conf->THEME_ELDY_USE_CHECKED)); + $colorbacklinepairhover=((! isset($user->conf->THEME_ELDY_USE_HOVER) || $user->conf->THEME_ELDY_USE_HOVER === '255,255,255')?'':($user->conf->THEME_ELDY_USE_HOVER === '1'?'edf4fb':$user->conf->THEME_ELDY_USE_HOVER)); + $colorbacklinepairchecked=((! isset($user->conf->THEME_ELDY_USE_CHECKED) || $user->conf->THEME_ELDY_USE_CHECKED === '255,255,255')?'':($user->conf->THEME_ELDY_USE_CHECKED === '1'?'edf4fb':$user->conf->THEME_ELDY_USE_CHECKED)); } if (empty($colortopbordertitle1)) $colortopbordertitle1=$colorbackhmenu1; @@ -504,6 +504,9 @@ input[name=weight], input[name=volume], input[name=surface], input[name=sizeheig input[name=surface] { margin-right: 4px; } fieldset { border: 1px solid #AAAAAA !important; } .legendforfieldsetstep { padding-bottom: 10px; } +input#onlinepaymenturl, input#directdownloadlink { + opacity: 0.7; +} div#moretabsListaction { z-index: 5; diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 242ca73d1bd..e2a9038ee62 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -312,7 +312,6 @@ if ($result) { print ''.$langs->trans("FullList").''; print ''; if ($num > 0) { - while ($i < $num) { $objp = $db->fetch_object($result); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index c567763c292..bfaa8ad3876 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -312,7 +312,6 @@ if ($socid && ! $projectid && ! $project_ref && $user->rights->societe->lire) { $socstat = new Societe($db); $res = $socstat->fetch($socid); if ($res > 0) { - $tmpobject = $object; $object = $socstat; // $object must be of type Societe when calling societe_prepare_head $head = societe_prepare_head($socstat); @@ -524,15 +523,15 @@ foreach($object->fields as $key => $val) if (! empty($arrayfields['t.'.$key]['checked'])) { if ($key == 'type_code') { print ''; - $formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 0, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + $formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); print ''; } elseif ($key == 'category_code') { print ''; - $formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 0, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + $formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); print ''; } elseif ($key == 'severity_code') { print ''; - $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 0, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); print ''; } elseif ($key == 'fk_user_assign') { print ''; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index d4b6de95530..d5a3afda413 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -114,7 +114,6 @@ $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) { if ($id <> $user->id) { $object->fetch($id); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 7d629acc4d2..683d7291525 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1471,7 +1471,6 @@ class User extends CommonObject $i = 0; while ($i < $num) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$rd[$i]"; $result=$this->db->query($sql); diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index e2369892fca..2eb94ac4835 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -206,7 +206,6 @@ class UserBankAccount extends Account $rib = ''; if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { - if ($this->label && $displayriblabel) { $rib = $this->label." : "; } diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 0922e9e63cf..79b285bc114 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -149,7 +149,6 @@ if ($id > 0) } else // View mode { - print ''; if (! empty($user->admin)) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index df2f3493b7f..54f39625ad4 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -91,7 +91,6 @@ $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - if ($cancel) { if (! empty($backtopage)) diff --git a/htdocs/user/list.php b/htdocs/user/list.php index d65d852294f..5520465a75d 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -198,7 +198,9 @@ $sql.= " u.tms as date_update, u.datec as date_creation,"; $sql.= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2,"; $sql.= " s.nom as name, s.canvas"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['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 diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 9ce745cf06c..b48823d2aa0 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -300,7 +300,6 @@ if ($result > 0) while ($i < $num) { - $obj = $db->fetch_object($resql); $userstatic->id=$obj->userid; diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 8f85465cde2..c77e7f1dd86 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -130,11 +130,9 @@ if ($action == 'buildnewpassword' && $username) } else { - // Success if ($edituser->send_password($edituser, $newpassword, 1) > 0) { - $message = '
'.$langs->trans("PasswordChangeRequestSent", $edituser->login, dolObfuscateEmail($edituser->email)).'
'; $username=''; } diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 913f0ba1ac0..a49c3e930b0 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -283,12 +283,12 @@ print ''; print ''."\n"; //print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS; -$sql = "SELECT r.id, r.libelle, r.module"; +$sql = "SELECT r.id, r.libelle, r.module, r.module_position"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql.= " AND r.entity = " . $entity; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable -$sql.= " ORDER BY r.module, r.id"; +$sql.= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $result=$db->query($sql); if ($result) @@ -301,12 +301,28 @@ if ($result) { $obj = $db->fetch_object($result); - // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore + // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it if (empty($modules[$obj->module])) { $i++; continue; } + + // Save field module_position in database if value is still zero + if (empty($obj->module_position)) + { + if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) + { + // TODO Define familyposition + $family = $modules[$obj->module]->family_position; + $familyposition = 0; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; + $sqlupdate.= " family_position = ".$familyposition; + $sqlupdate.= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; + $db->query($sqlupdate); + } + } + if (isset($obj->module) && ($oldmod <> $obj->module)) { $oldmod = $obj->module; @@ -331,11 +347,15 @@ if ($result) print 'module.'">'.$langs->trans("None").""; print ''; } - print ''; - }else { - print ''; + print ''; + } else { + if ($caneditperms) + { + print ''; + } + print ''; } - print ''; + print ''; print ''."\n"; } diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index 1a61000f07e..b6bfb90e22c 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -27,7 +27,6 @@ if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->e accessforbidden(); if ($_POST) { - $value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD'); if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) { diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 013c5489670..e425aa16c5d 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -44,9 +44,7 @@ if ($object->fetch($id) < 1) { if ($cancel) $action=''; if ($_POST) { - if ($action == 'edit') { - $object->ref = $ref; $object->label = $label; @@ -58,9 +56,7 @@ if ($_POST) { exit(); } } elseif ($action == 'update') { - if ($objectval->fetch($valueid) > 0) { - $objectval->ref = $ref; $objectval->value = GETPOST('value', 'alpha'); @@ -92,7 +88,6 @@ if ($_POST) { if ($confirm == 'yes') { if ($action == 'confirm_delete') { - $db->begin(); $res = $objectval->deleteByFkAttribute($object->id); @@ -111,7 +106,6 @@ if ($confirm == 'yes') { elseif ($action == 'confirm_deletevalue') { if ($objectval->fetch($valueid) > 0) { - if ($objectval->delete() < 1) { setEventMessages($langs->trans('CoreErrorMessage'), $objectval->errors, 'errors'); } else { @@ -198,7 +192,6 @@ if ($action == 'edit') { ?> formconfirm( 1 ); } elseif ($action == 'delete_value') { - if ($objectval->fetch($valueid) > 0) { - $form = new Form($db); print $form->formconfirm( diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index 83c97892fd2..139c919bb18 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -111,7 +111,6 @@ class ProductAttribute if ($query) { while ($result = $this->db->fetch_object($query)) { - $tmp = new ProductAttribute($this->db); $tmp->id = $result->rowid; $tmp->ref = $result->ref; diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index 6dbc558f2c7..e2a99de90d2 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -129,7 +129,6 @@ class ProductAttributeValue $query = $this->db->query($sql); while ($result = $this->db->fetch_object($query)) { - $tmp = new ProductAttributeValue($this->db); $tmp->fk_product_attribute = $result->fk_product_attribute; $tmp->id = $result->rowid; diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 093ed390fe7..db0d49a0e36 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -167,7 +167,6 @@ class ProductCombination $return = array(); while ($result = $this->db->fetch_object($query)) { - $tmp = new ProductCombination($this->db); $tmp->id = $result->rowid; $tmp->fk_product_parent = $result->fk_product_parent; @@ -290,7 +289,6 @@ class ProductCombination $this->db->begin(); foreach ($this->fetchAllByFkProductParent($fk_product_parent) as $prodcomb) { - $prodstatic = new Product($this->db); $res = $prodstatic->fetch($prodcomb->fk_product_child); @@ -334,7 +332,6 @@ class ProductCombination $child->label = $parent->label.$varlabel; if ($child->update($child->id, $user) > 0) { - $new_vat = $parent->tva_tx; $new_npr = $parent->tva_npr; @@ -420,7 +417,6 @@ class ProductCombination } foreach ($prodcomb->fetchAllByFkProductParent($prodid) as $prc) { - $values = array(); foreach ($prodcomb2val->fetchByFkCombination($prc->id) as $value) { @@ -551,7 +547,6 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; // $combination contains list of attributes pairs key->value. Example: array('id Color'=>id Blue, 'id Size'=>id Small, 'id Option'=>id val a, ...) //var_dump($combinations); foreach ($combinations as $currcombattr => $currcombval) { - //This was checked earlier, so no need to double check $prodattr->fetch($currcombattr); $prodattrval->fetch($currcombval); @@ -683,7 +678,6 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; $combinations = $this->fetchAllByFkProductParent($origProductId); foreach ($combinations as $combination) { - $variations = array(); foreach ($prodcomb2val->fetchByFkCombination($combination->id) as $tmp_pc2v) { diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 349dbdd03ec..080242d3137 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -96,7 +96,6 @@ $prodcomb2val = new ProductCombination2ValuePair($db); $productCombination2ValuePairs1 = array(); if ($_POST) { - if (($action == 'add' || $action == 'create') && empty($massaction) && ! GETPOST('selectvariant', 'alpha')) // We click on Create all defined combinations { //$features = GETPOST('features', 'array'); @@ -113,7 +112,6 @@ if ($_POST) { //First, sanitize foreach ($features as $feature) { - $explode = explode(':', $feature); if ($prodattr->fetch($explode[0]) < 0) { @@ -173,7 +171,6 @@ if ($_POST) { $db->begin(); foreach ($toselect as $prodid) { - if ($prodstatic->fetch($prodid) < 0) { continue; } @@ -216,7 +213,6 @@ if ($_POST) { } } elseif ($valueid > 0) { - if ($prodcomb->fetch($valueid) < 0) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); exit(); @@ -240,9 +236,7 @@ if ($_POST) { $productCombinations = $prodcomb->fetchAllByFkProductParent($object->id); if ($action === 'confirm_deletecombination') { - if ($prodcomb->fetch($valueid) > 0) { - $db->begin(); if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) { @@ -257,7 +251,6 @@ if ($action === 'confirm_deletecombination') { $action = ''; } } elseif ($action === 'edit') { - if ($prodcomb->fetch($valueid) < 0) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); exit(); @@ -269,12 +262,10 @@ if ($action === 'confirm_deletecombination') { $productCombination2ValuePairs1 = $prodcomb2val->fetchByFkCombination($valueid); } elseif ($action === 'confirm_copycombination') { - //Check destination product $dest_product = GETPOST('dest_product'); if ($prodstatic->fetch('', $dest_product) > 0) { - //To prevent from copying to the same product if ($prodstatic->ref != $object->ref) { if ($prodcomb->copyAll($object->id, $prodstatic) > 0) { @@ -381,7 +372,6 @@ if (! empty($id) || ! empty($ref)) // Create or edit a varian if ($action == 'add' || ($action == 'edit')) { - if ($action == 'add') { $title = $langs->trans('NewProductCombination'); //print dol_fiche_head(); @@ -390,7 +380,6 @@ if (! empty($id) || ! empty($ref)) $listofvariantselected = '
'; if (! empty($features)) { foreach ($features as $feature) { - $explode = explode(':', $feature); if ($prodattr->fetch($explode[0]) < 0) { @@ -634,7 +623,6 @@ if (! empty($id) || ! empty($ref)) else { if ($action === 'delete') { - if ($prodcomb->fetch($valueid) > 0) { $prodstatic->fetch($prodcomb->fk_product_child); diff --git a/htdocs/variants/create.php b/htdocs/variants/create.php index 538b0d45cfa..e579ea95d04 100644 --- a/htdocs/variants/create.php +++ b/htdocs/variants/create.php @@ -32,7 +32,6 @@ if ($_POST) { if (empty($ref) || empty($label)) { setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { - $prodattr = new ProductAttribute($db); $prodattr->label = $label; $prodattr->ref = $ref; diff --git a/htdocs/variants/create_val.php b/htdocs/variants/create_val.php index 6d2e78d8ea4..260665a0155 100644 --- a/htdocs/variants/create_val.php +++ b/htdocs/variants/create_val.php @@ -61,7 +61,6 @@ if ($action == 'add') if (empty($ref) || empty($value)) { setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { - $objectval->fk_product_attribute = $object->id; $objectval->ref = $ref; $objectval->value = $value; diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index 42a27560a19..57b9963d9b4 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -84,7 +84,6 @@ if ($_POST) } if ($sanitized_values) { - require DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $adapted_values = array(); @@ -106,7 +105,6 @@ if ($_POST) //Current combinations will be deleted if ($delete_prev_comb_res > 0) { - $res = 1; $cartesianarray = cartesianArray($adapted_values); diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index 7feca5f3ff4..404533ece96 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -534,7 +534,6 @@ function updateActionComm($authentication, $actioncomm) $result=$object->fetch($actioncomm['id']); if (!empty($object->id)) { - $objectfound=true; $object->datep=$actioncomm['datep']; diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index dedef77728c..ba27613a371 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -385,8 +385,6 @@ function createContact($authentication, $contact) if (! $error) { - - $newobject=new Contact($db); $newobject->id=$contact['id']; @@ -645,7 +643,6 @@ function updateContact($authentication, $contact) $result=$object->fetch($contact['id'], 0, $contact['ref_ext']); if (!empty($object->id)) { - $objectfound=true; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 6e5ab78bfad..105582f8fcd 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -697,7 +697,6 @@ dol_syslog("Function: createInvoiceFromOrder login=".$authentication['login']." if(!$error) { - $newobject=new Facture($db); $result = $newobject->createFromOrder($order, $fuser); @@ -768,7 +767,6 @@ dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$inv $result=$object->fetch($invoice['id'], $invoice['ref'], $invoice['ref_ext'], ''); if (!empty($object->id)) { - $objectfound=true; $db->begin(); diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 4c5a2266106..82c40bc60cf 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -395,7 +395,6 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') if(!$error) { - $linesresp=array(); $i=0; foreach($order->lines as $line) @@ -558,7 +557,6 @@ function getOrdersForThirdParty($authentication, $idthirdparty) if(!$error) { - // Define lines of invoice $linesresp=array(); foreach($order->lines as $line) @@ -837,7 +835,6 @@ function validOrder($authentication, $id = '', $id_warehouse = 0) $db->begin(); if ($result > 0) { - $result=$order->valid($fuser, $id_warehouse); if ($result >= 0) @@ -921,7 +918,6 @@ function updateOrder($authentication, $order) $result=$object->fetch($order['id'], (empty($order['id'])?$order['ref']:''), (empty($order['id']) && empty($order['ref'])?$order['ref_ext']:'')); if (!empty($object->id)) { - $objectfound=true; $db->begin(); diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 960a3bbcf0f..8c9d4bbf5ed 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -365,7 +365,6 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '' if (! $error) { - $langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT)); $langs->setDefaultLang($langcode); diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 131170f6691..a1d7df691de 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -318,7 +318,6 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') $result=$thirdparty->fetch($id, $ref, $ref_ext); if ($result > 0) { - $thirdparty_result_fields=array( 'id' => $thirdparty->id, 'ref' => $thirdparty->name, @@ -570,7 +569,6 @@ function updateThirdParty($authentication, $thirdparty) $result=$object->fetch($thirdparty['id']); if (!empty($object->id)) { - $objectfound=true; $object->ref=$thirdparty['ref']; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 94735a65eff..cf695edf439 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1204,7 +1204,6 @@ class Website extends CommonObject $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile)); if ($pageid > 0) { - $languagecodeselected=$tmppage->lang; if (! in_array($tmppage->lang, $languagecodes)) $languagecodes[]=$tmppage->lang; // We add language code of page into combo list } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index fa13e88b481..1eff07edb39 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3028,7 +3028,6 @@ if ($action == 'editmeta' || $action == 'createcontainer') $result = $sourcepage->fetch($objectpage->fk_page); if ($result == 0) // not found, we can reset value { - } elseif ($result > 0) { diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index 2a6858b0e90..4a55aa81376 100755 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -158,7 +158,6 @@ if ($resql) { // export csv if (GETPOST('action', 'aZ09') == 'export_csv') { - header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=export_csv.csv'); diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 9b990d78922..d73d99f7078 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -413,11 +413,11 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $result=dol_compress_file($filein, $fileout, $format, $errorstring); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." : ".$errorstring); + $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." into ".$fileout." : ".$errorstring); $result=dol_uncompress($fileout, $dirout); print __METHOD__." result=".join(',', $result)."\n"; - $this->assertEquals(0, count($result), "Pb with dol_uncompress_file"); + $this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout); } /**
'.$langs->trans("Permissions").'