diff --git a/ChangeLog b/ChangeLog index a5096950ea5..ae767c91649 100644 --- a/ChangeLog +++ b/ChangeLog @@ -125,6 +125,7 @@ NEW: VAT Report by month - Show detail by rate and also by code NEW: Ticket triggers: allow to automatically send messages on new tickets NEW: Accountancy - Add hidden feature for accounting reconciliation NEW: Can store the session into database (instead of beeing managed by PHP) +NEW: Added MMK currency (Myanmar Kyat) Modules NEW: Module Partnership Management diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 02b95cfd043..15428e356c8 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -220,7 +220,7 @@ llxheader('', $title, $help_url); // Create mode -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans('NewAccountingAccount')); print '
'."\n"; diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 2aa33f21645..96f9d988ebb 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -154,7 +154,7 @@ $help_url = "EN:Module_Double_Entry_Accounting"; llxHeader('', $title, $help_url); -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewFiscalYear")); print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 7c8c0dca547..5f4ebcc22fc 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -340,7 +340,7 @@ if ($action == 'delete') { print $formconfirm; } -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("CreateMvts")); $object = new BookKeeping($db); diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0096ba9a285..4731414f285 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -920,7 +920,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // Create mode - if ($action == 'create') { + if ($action == 'create' || (empty($action) && empty($id))) { $object->canvas = $canvas; $object->state_id = GETPOST('state_id', 'int'); diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index ab4f0c7def0..9f0986ad8f2 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -253,7 +253,7 @@ $help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électro llxHeader('', 'EmailCollector', $help_url); // Part to create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewEmailCollector", $langs->transnoentitiesnoconv("EmailCollector"))); print ''; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 7d02aea0e73..d38fe0f6b37 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -197,8 +197,25 @@ print ''; print ''; print ''; +print ''; -print '
'; +print ''; + +print '';*/ +// Filter on categories +if (!empty($conf->global->MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + $moreforfilter .= '
'; + $tmptitle = $langs->transnoentities('ProductsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); + $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); + $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -'; + $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle); + $moreforfilter .= ' '; + $moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_pro'); // Tooltip on click + $moreforfilter .= '
'; +} + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 311b04a4c89..e58a15f906a 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -290,7 +290,7 @@ $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("", $title, $help_url); -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewWarehouse"), '', 'stock'); dol_set_focus('input[name="libelle"]'); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 6e6f8991e83..8b2c0720c47 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -378,7 +378,7 @@ llxHeader('', $title, $help_url); // Part to create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("Batch"), '', 'object_'.$object->picto); print ''; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index b009ace7275..cf8f9fdf572 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -413,7 +413,7 @@ print '}); // Part to create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("StockTransfer")), '', 'object_'.$object->picto); print ''; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index a213f417650..097d670e8ea 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -806,7 +806,7 @@ if ($action == 'create' && $user->rights->projet->creer) { if ($action == 'clone') { $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200 maxwidth250')), array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), @@ -815,7 +815,7 @@ if ($action == 'create' && $user->rights->projet->creer) { array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) ); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 400, 590); } @@ -1293,7 +1293,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print dolGetButtonAction('', $langs->trans('ExportAccountingReportButtonLabel'), 'default', $url, ''); } */ - + // Modify if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) { if ($userWrite > 0) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index ba31845592a..d9ad1111fc7 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -127,6 +127,7 @@ class Task extends CommonObjectLine public $timespent_fk_user; public $timespent_thm; public $timespent_note; + public $timespent_fk_product; public $comments = array(); @@ -1227,6 +1228,7 @@ class Task extends CommonObjectLine $sql .= ", task_date_withhour"; $sql .= ", task_duration"; $sql .= ", fk_user"; + $sql .= ", fk_product"; $sql .= ", note"; $sql .= ", datec"; $sql .= ") VALUES ("; @@ -1236,6 +1238,7 @@ class Task extends CommonObjectLine $sql .= ", ".(empty($this->timespent_withhour) ? 0 : 1); $sql .= ", ".((int) $this->timespent_duration); $sql .= ", ".((int) $this->timespent_fk_user); + $sql .= ", ".((int) $this->timespent_fk_product); $sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ")"; @@ -1523,6 +1526,7 @@ class Task extends CommonObjectLine $sql .= " t.task_date_withhour,"; $sql .= " t.task_duration,"; $sql .= " t.fk_user,"; + $sql .= " t.fk_product,"; $sql .= " t.thm,"; $sql .= " t.note"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; @@ -1541,6 +1545,7 @@ class Task extends CommonObjectLine $this->timespent_withhour = $obj->task_date_withhour; $this->timespent_duration = $obj->task_duration; $this->timespent_fk_user = $obj->fk_user; + $this->timespent_fk_product = $obj->fk_product; $this->timespent_thm = $obj->thm; // hourly rate $this->timespent_note = $obj->note; } @@ -1694,6 +1699,7 @@ class Task extends CommonObjectLine $sql .= " task_date_withhour = ".(empty($this->timespent_withhour) ? 0 : 1).","; $sql .= " task_duration = ".((int) $this->timespent_duration).","; $sql .= " fk_user = ".((int) $this->timespent_fk_user).","; + $sql .= " fk_product = ".((int) $this->timespent_fk_product).","; $sql .= " note = ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); $sql .= " WHERE rowid = ".((int) $this->timespent_id); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index f409b3cb547..0859a7d9910 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -73,6 +73,7 @@ $search_task_ref = GETPOST('search_task_ref', 'alpha'); $search_task_label = GETPOST('search_task_label', 'alpha'); $search_user = GETPOST('search_user', 'int'); $search_valuebilled = GETPOST('search_valuebilled', 'int'); +$search_product_ref = GETPOST('search_product_ref', 'alpha'); $search_company = GETPOST('$search_company', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -166,6 +167,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_task_label = ''; $search_user = 0; $search_valuebilled = ''; + $search_product_ref = ''; $toselect = array(); $search_array_options = array(); $action = ''; @@ -220,6 +222,7 @@ if ($action == 'addtimespent' && $user->rights->projet->time) { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth", 'int'), GETPOST("timeday", 'int'), GETPOST("timeyear", 'int')); } $object->timespent_fk_user = GETPOST("userid", 'int'); + $object->timespent_fk_product = GETPOST("fk_product", 'int'); $result = $object->addTimeSpent($user); if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -271,17 +274,17 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); } $object->timespent_fk_user = GETPOST("userid_line", 'int'); + $object->timespent_fk_product = GETPOST("fk_product", 'int'); $result = 0; if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) { $result = $object->addTimeSpent($user); - } - - if ($result >= 0) { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans($object->error), null, 'errors'); - $error++; + if ($result >= 0) { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans($object->error), null, 'errors'); + $error++; + } } } else { $object->fetch($id, $ref); @@ -298,6 +301,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth", 'int'), GETPOST("timelineday", 'int'), GETPOST("timelineyear", 'int')); } $object->timespent_fk_user = GETPOST("userid_line", 'int'); + $object->timespent_fk_product = GETPOST("fk_product", 'int'); $result = 0; if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) { @@ -391,36 +395,22 @@ if ($action == 'confirm_generateinvoice') { $generateinvoicemode = GETPOST('generateinvoicemode', 'string'); $invoiceToUse = GETPOST('invoiceid', 'int'); - $prodDurationHours = 1.0; + $prodDurationHoursBase = 1.0; + $product_data_cache = array(); if ($idprod > 0) { $tmpproduct->fetch($idprod); + if ($result<0) { + $error++; + setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); + } - if (empty($tmpproduct->duration_value)) { + $prodDurationHoursBase=$tmpproduct->getProductDurationHours(); + if ($prodDurationHoursBase<0) { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice"), null, 'errors'); + setEventMessages(null, $tmpproduct->errors, 'errors'); } - if ($tmpproduct->duration_unit == 'i') { - $prodDurationHours = 1. / 60; - } - if ($tmpproduct->duration_unit == 'h') { - $prodDurationHours = 1.; - } - if ($tmpproduct->duration_unit == 'd') { - $prodDurationHours = 24.; - } - if ($tmpproduct->duration_unit == 'w') { - $prodDurationHours = 24. * 7; - } - if ($tmpproduct->duration_unit == 'm') { - $prodDurationHours = 24. * 30; - } - if ($tmpproduct->duration_unit == 'y') { - $prodDurationHours = 24. * 365; - } - $prodDurationHours *= $tmpproduct->duration_value; - $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); $pu_ht = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; @@ -428,7 +418,7 @@ if ($action == 'confirm_generateinvoice') { $localtax1 = $dataforprice['localtax1']; $localtax2 = $dataforprice['localtax2']; } else { - $prodDurationHours = 1; + $prodDurationHoursBase = 1; $pu_ht = 0; $txtva = get_default_tva($mysoc, $projectstatic->thirdparty); @@ -456,39 +446,85 @@ if ($action == 'confirm_generateinvoice') { foreach ($toselect as $key => $value) { // Get userid, timepent $object->fetchTimeSpent($value); - $arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration; - $arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); + $arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); } - foreach ($arrayoftasks as $userid => $value) { + foreach ($arrayoftasks as $userid => $data) { $fuser->fetch($userid); //$pu_ht = $value['timespent'] * $fuser->thm; $username = $fuser->getFullName($langs); + foreach ($data as $fk_product=>$timespent_data) { + // Define qty per hour + $qtyhour = $timespent_data['timespent'] / 3600; + $qtyhourtext = convertSecondToTime($timespent_data['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); - // Define qty per hour - $qtyhour = $value['timespent'] / 3600; - $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + // If no unit price known + if (empty($pu_ht)) { + $pu_ht = price2num($timespent_data['totalvaluetodivideby3600'] / 3600, 'MU'); + } - // If no unit price known - if (empty($pu_ht)) { - $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); - } + // Add lines + $prodDurationHours = $prodDurationHoursBase; + $idprodline=$idprod; + $pu_htline = $pu_ht; + $txtvaline = $txtva; + $localtax1line = $localtax1; + $localtax2line = $localtax2; - // Add lines - $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + if (!empty($fk_product) && $fk_product!==$idprod) { + if (!array_key_exists($fk_product, $product_data_cache)) { + $result = $tmpproduct->fetch($fk_product); + if ($result < 0) { + $error++; + setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); + } + $prodDurationHours = $tmpproduct->getProductDurationHours(); + if ($prodDurationHours < 0) { + $error++; + $langs->load("errors"); + setEventMessages(null, $tmpproduct->errors, 'errors'); + } - // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); - $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); - $result = $db->query($sql); - if (!$result) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; + $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); + + $pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; + $txtvaline = $dataforprice['tva_tx']; + $localtax1line = $dataforprice['localtax1']; + $localtax2line = $dataforprice['localtax2']; + + $product_data_cache[$fk_product] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice); + } else { + $prodDurationHours = $product_data_cache[$fk_product]['duration']; + $pu_htline = empty($product_data_cache[$fk_product]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$fk_product]['dataforprice']['pu_ht']; + $txtvaline = $product_data_cache[$fk_product]['dataforprice']['tva_tx']; + $localtax1line = $product_data_cache[$fk_product]['dataforprice']['localtax1']; + $localtax2line = $product_data_cache[$fk_product]['dataforprice']['localtax2']; + } + $idprodline=$fk_product; + } + + // Add lines + $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0)); + if ($lineid<0) { + $error++; + setEventMessages(null, $tmpinvoice->errors, 'errors'); + } + + // Update lineid into line of timespent + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); + $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); + $result = $db->query($sql); + if (!$result) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } } } } elseif ($generateinvoicemode == 'onelineperperiod') { // One line for each time spent line $arrayoftasks = array(); + $withdetail=GETPOST('detail_time_duration', 'alpha'); foreach ($toselect as $key => $value) { // Get userid, timepent @@ -518,6 +554,7 @@ if ($action == 'confirm_generateinvoice') { $arrayoftasks[$object->timespent_id]['note'] .= ' - '.$langs->trans("Duration").': '.convertSecondToTime($object->timespent_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); } $arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user; + $arrayoftasks[$object->timespent_id]['fk_product'] = $object->timespent_fk_product; } foreach ($arrayoftasks as $timespent_id => $value) { @@ -533,7 +570,49 @@ if ($action == 'confirm_generateinvoice') { } // Add lines - $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $prodDurationHours = $prodDurationHoursBase; + $idprodline=$idprod; + $pu_htline = $pu_ht; + $txtvaline = $txtva; + $localtax1line = $localtax1; + $localtax2line = $localtax2; + + if (!empty($value['fk_product']) && $value['fk_product']!==$idprod) { + if (!array_key_exists($value['fk_product'], $product_data_cache)) { + $result = $tmpproduct->fetch($value['fk_product']); + if ($result < 0) { + $error++; + setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); + } + $prodDurationHours = $tmpproduct->getProductDurationHours(); + if ($prodDurationHours < 0) { + $error++; + $langs->load("errors"); + setEventMessages(null, $tmpproduct->errors, 'errors'); + } + + $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); + + $pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; + $txtvaline = $dataforprice['tva_tx']; + $localtax1line = $dataforprice['localtax1']; + $localtax2line = $dataforprice['localtax2']; + + $product_data_cache[$value['fk_product']] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice); + } else { + $prodDurationHours = $product_data_cache[$value['fk_product']]['duration']; + $pu_htline = empty($product_data_cache[$value['fk_product']]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$value['fk_product']]['dataforprice']['pu_ht']; + $txtvaline = $product_data_cache[$value['fk_product']]['dataforprice']['tva_tx']; + $localtax1line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax1']; + $localtax2line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax2']; + } + $idprodline=$value['fk_product']; + } + $lineid = $tmpinvoice->addline($value['note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0)); + if ($lineid<0) { + $error++; + setEventMessages(null, $tmpinvoice->errors, 'errors'); + } //var_dump($lineid);exit; // Update lineid into line of timespent @@ -552,56 +631,99 @@ if ($action == 'confirm_generateinvoice') { // Get userid, timepent $object->fetchTimeSpent($value); // Call method to get list of timespent for a timespent line id (We use the utiliy method found into Task object) // $object->id is now the task id - $arrayoftasks[$object->id]['timespent'] += $object->timespent_duration; - $arrayoftasks[$object->id]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); + $arrayoftasks[$object->id][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->id][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); } - foreach ($arrayoftasks as $task_id => $value) { + foreach ($arrayoftasks as $task_id => $data) { $ftask = new Task($db); $ftask->fetch($task_id); - // Define qty per hour - $qtyhour = $value['timespent'] / 3600; - $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); - if ($idprod > 0) { - // If a product is defined, we msut use the $prodDurationHours and $pu_ht of product (already set previously). - $pu_ht_for_task = $pu_ht; - // If we want to reuse the value of timespent (so use same price than cost price) - if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) { - $pu_ht_for_task = price2num($value['totalvaluetodivideby3600'] / $value['timespent'], 'MU') * $prodDurationHours; + foreach ($data as $fk_product=>$timespent_data) { + $qtyhour = $timespent_data['timespent'] / 3600; + $qtyhourtext = convertSecondToTime($timespent_data['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + + // Add lines + $prodDurationHours = $prodDurationHoursBase; + $idprodline=$idprod; + $pu_htline = $pu_ht; + $txtvaline = $txtva; + $localtax1line = $localtax1; + $localtax2line = $localtax2; + + if (!empty($fk_product) && $fk_product!==$idprod) { + if (!array_key_exists($fk_product, $product_data_cache)) { + $result = $tmpproduct->fetch($fk_product); + if ($result < 0) { + $error++; + setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); + } + $prodDurationHours = $tmpproduct->getProductDurationHours(); + if ($prodDurationHours < 0) { + $error++; + $langs->load("errors"); + setEventMessages(null, $tmpproduct->errors, 'errors'); + } + + $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); + + $pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; + $txtvaline = $dataforprice['tva_tx']; + $localtax1line = $dataforprice['localtax1']; + $localtax2line = $dataforprice['localtax2']; + + $product_data_cache[$fk_product] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice); + } else { + $prodDurationHours = $product_data_cache[$fk_product]['duration']; + $pu_htline = empty($product_data_cache[$fk_product]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$fk_product]['dataforprice']['pu_ht']; + $txtvaline = $product_data_cache[$fk_product]['dataforprice']['tva_tx']; + $localtax1line = $product_data_cache[$fk_product]['dataforprice']['localtax1']; + $localtax2line = $product_data_cache[$fk_product]['dataforprice']['localtax2']; + } + $idprodline=$fk_product; } - $pa_ht = price2num($value['totalvaluetodivideby3600'] / $value['timespent'], 'MU') * $prodDurationHours; - } else { - // If not product used, we use the hour unit for duration and unit price. - $pu_ht_for_task = 0; - // If we want to reuse the value of timespent (so use same price than cost price) - if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) { - $pu_ht_for_task = price2num($value['totalvaluetodivideby3600'] / $value['timespent'], 'MU'); + + + if ($idprodline > 0) { + // If a product is defined, we msut use the $prodDurationHours and $pu_ht of product (already set previously). + $pu_ht_for_task = $pu_htline; + // If we want to reuse the value of timespent (so use same price than cost price) + if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) { + $pu_ht_for_task = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU') * $prodDurationHours; + } + $pa_ht = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU') * $prodDurationHours; + } else { + // If not product used, we use the hour unit for duration and unit price. + $pu_ht_for_task = 0; + // If we want to reuse the value of timespent (so use same price than cost price) + if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) { + $pu_ht_for_task = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU'); + } + $pa_ht = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU'); } - $pa_ht = price2num($value['totalvaluetodivideby3600'] / $value['timespent'], 'MU'); - } - // Add lines - $date_start = ''; - $date_end = ''; - $lineName = $ftask->ref.' - '.$ftask->label; - $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task, price2num($qtyhour / $prodDurationHours, 'MS'), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0), 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1, -1, 0, '', 0, 0, null, $pa_ht); - if ($lineid < 0) { - $error++; - setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); - break; - } - - if (!$error) { - // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); - $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).')'; - $result = $db->query($sql); - if (!$result) { + // Add lines + $date_start = ''; + $date_end = ''; + $lineName = $ftask->ref . ' - ' . $ftask->label; + $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task, price2num($qtyhour / $prodDurationHours, 'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1, -1, 0, '', 0, 0, null, $pa_ht); + if ($lineid < 0) { $error++; - setEventMessages($db->lasterror(), null, 'errors'); + setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); break; } + + if (!$error) { + // Update lineid into line of timespent + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'projet_task_time SET invoice_line_id = ' . ((int) $lineid) . ', invoice_id = ' . ((int) $tmpinvoice->id); + $sql .= ' WHERE rowid IN (' . $db->sanitize(join(',', $toselect)) . ')'; + $result = $db->query($sql); + if (!$result) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } } } } @@ -1085,6 +1207,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1); $arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1); + if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + $arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1); + } $arrayfields['t.task_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1); $arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1)); $arrayfields['valuebilled'] = array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((!empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT)) ? 0 : 1) && $projectstatic->usage_bill_time)); @@ -1312,6 +1437,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $tasks = array(); $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; + $sql .= " t.fk_product,"; $sql .= " pt.ref, pt.label, pt.fk_projet,"; $sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,"; $sql .= " il.fk_facture as invoice_id, inv.fk_statut,"; @@ -1324,9 +1450,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as prod ON prod.rowid = t.fk_product"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as pt ON pt.rowid = t.fk_task"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = pt.fk_projet"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; // Add table from hooks @@ -1363,6 +1490,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_user > 0) { $sql .= natural_search('t.fk_user', $search_user, 2); } + if (!empty($search_product_ref)) { + $sql .= natural_search('prod.ref', $search_product_ref); + } if ($search_valuebilled == '1') { $sql .= ' AND t.invoice_id > 0'; } @@ -1461,6 +1591,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''.$langs->trans("ProgressDeclared").''; if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''; + + if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + print ''.$langs->trans("Product").''; + } } // Hook fields $parameters = array('mode' => 'create'); @@ -1536,6 +1670,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''; print ''; + + if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + print ''; + print $form->select_produits('', 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); + print ''; + } } // Fields from hook @@ -1619,6 +1759,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['t.task_duration']['checked'])) { print ''; } + // Product + if (!empty($arrayfields['t.fk_product']['checked'])) { + print ''; + } // Value in main currency if (!empty($arrayfields['value']['checked'])) { print ''; @@ -1670,6 +1814,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['t.task_duration']['checked'])) { print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, '', $sortfield, $sortorder, 'right '); } + if (!empty($arrayfields['t.fk_product']['checked'])) { + print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['value']['checked'])) { print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); } @@ -1860,6 +2008,23 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $totalarray['totalduration'] += $task_time->task_duration; } + //Product + if (!empty($arrayfields['t.fk_product']['checked'])) { + print ''; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { + $form->select_produits($task_time->fk_product, 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); + } elseif (!empty($task_time->fk_product)) { + $product = new Product($db); + $resultFetch = $product->fetch($task_time->fk_product); + if ($resultFetch < 0) { + setEventMessages($product->error, $product->errors, 'errors'); + } else { + print $product->getNomUrl(1); + } + } + print ''; + } + // Value spent if (!empty($arrayfields['value']['checked'])) { $langs->load("salaries"); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index ed4586a7376..c8feafb146d 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -728,7 +728,7 @@ if ($action == 'create2') { } // Mode creation. -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { $recept = new Reception($db); print load_fiche_titre($langs->trans("CreateReception")); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index f7d695abaad..9eec935728e 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -864,6 +864,7 @@ class Reception extends CommonObject $line->status = 1; $line->cost_price = $cost_price; $line->fk_reception = $this->id; + $this->lines[$num] = $line; return $num; diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 0da5badd7bc..076778fd56f 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -283,7 +283,7 @@ llxHeader('', $title, $help_url); // Part to create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("RecruitmentCandidature")), '', 'object_'.$object->picto); print ''; diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index b2172aca80d..f1567ae0ae4 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -202,7 +202,7 @@ $help_url = ''; llxHeader('', $title, $help_url); // Part to create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto); print ''; diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 4ffbe1eb0a7..40ba3e8b4dc 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -197,7 +197,7 @@ $form = new Form($db); $formresource = new FormResource($db); if ($action == 'create' || $object->fetch($id, $ref) > 0) { - if ($action == 'create') { + if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($title, '', 'object_resource'); print dol_get_fiche_head(''); } else { diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 7d57575dacd..86711022c1e 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -457,7 +457,7 @@ if ($id > 0) { } // Create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 2fb9285379f..c57f1ac00da 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -51,19 +51,15 @@ $formcompany = new FormCompany($db); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setcodeclient') { - if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } if ($action == 'setcodecompta') { - if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -273,10 +269,8 @@ if ($action == 'setprofid') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_UNIQUE"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -286,10 +280,8 @@ if ($action == 'setprofidmandatory') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_MANDATORY"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -299,10 +291,8 @@ if ($action == 'setprofidinvoicemandatory') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -311,10 +301,8 @@ if ($action == 'setprofidinvoicemandatory') { if ($action == 'sethideinactivethirdparty') { $status = GETPOST('status', 'alpha'); - if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -331,6 +319,7 @@ if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { } } + /* * View */ @@ -575,7 +564,7 @@ foreach ($dirsociete as $dirroot) { if ($modulequalified) { print ''; - print $module->name; + print dol_escape_htmltag($module->name); print "\n"; if (method_exists($module, 'info')) { print $module->info($langs); @@ -589,7 +578,7 @@ foreach ($dirsociete as $dirroot) { print "\n"; //if ($conf->global->COMPANY_ADDON_PDF != "$name") //{ - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; //} @@ -605,7 +594,7 @@ foreach ($dirsociete as $dirroot) { print ""; } else { print ''."\n"; - print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print ""; } } @@ -626,7 +615,7 @@ foreach ($dirsociete as $dirroot) { // Preview print ''; if ($module->type == 'pdf') { - $linkspec = ''.img_object($langs->trans("Preview"), 'pdf').''; + $linkspec = ''.img_object($langs->trans("Preview"), 'pdf').''; } else { $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index aa784d8639d..c6b1aec4e4c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -981,7 +981,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used in standard mode // ----------------------------------------- - if ($action == 'create') { + if ($action == 'create' || (empty($action) && empty($id))) { /* * Creation */ diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 6253d9b86b2..af1288cfa66 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1141,7 +1141,7 @@ if (!empty($conf->project->enabled)) { $now = dol_now(); // Add new askprice -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { $currency_code = $conf->currency; print load_fiche_titre($langs->trans("SupplierProposalNew"), '', 'supplier_proposal'); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 35855b60e23..bdc11c79b2f 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -177,6 +177,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu } } + /* * Actions */ @@ -278,7 +279,8 @@ if (empty($reshook)) { $res = $invoice->validate($user); if ($res < 0) { $error++; - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + $langs->load("admin"); + dol_htmloutput_errors($invoice->error == 'NotConfigured' ? $langs->trans("NotConfigured").' (TakePos numbering module)': $invoice->error, $invoice->errors, 1); } } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 92d309e554b..61bcdc7cc57 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -259,7 +259,7 @@ $fuserstatic = new User($db); $form = new Form($db); $formfile = new FormFile($db); -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group'); dol_set_focus('#nom'); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 53eed056695..a47fa7a51c2 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -508,6 +508,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- +$title = $langs->trans("ListOfUsers"); llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 3337d846f0b..56c6d2d01f7 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -272,7 +272,7 @@ if ($result > 0) { print ''; - if ($action == 'create') { + if ($action == 'create' || (empty($action) && empty($id))) { // $listofemails=$object->thirdparty_and_contact_email_array(); if ($object->email) { $actions = array(); diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 68bb8d60998..470e3fd96f8 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -158,7 +158,7 @@ $help_url = 'EN:Module_Products#Variants'; llxHeader('', $title, $help_url); // Part to create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ProductAttribute")), '', 'object_' . $object->picto); print ''; diff --git a/htdocs/webhook/target_card.php b/htdocs/webhook/target_card.php index dd0d5e171e8..3ffd381f3aa 100644 --- a/htdocs/webhook/target_card.php +++ b/htdocs/webhook/target_card.php @@ -240,7 +240,7 @@ llxHeader('', $title, $help_url); // Part to create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { if (empty($permissiontoadd)) { accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1); exit; diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 249398c322e..7a075eb8734 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -118,7 +118,7 @@ $formfile = new FormFile($db); llxHeader('', 'WebsiteAccount', ''); // Part to create -if ($action == 'create') { +if ($action == 'create' || (empty($action) && empty($id))) { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("WebsiteAccount"))); print ''; diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index 9e859dcc2d0..a2409802024 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -186,7 +186,7 @@ llxHeader('', $title, $help_url); trans("NewObject", $langs->transnoentitiesnoconv("Workstation")), '', 'object_'.$object->picto); print ''; diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 82205369c86..47de2cbebcc 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -166,6 +166,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase print __METHOD__."\n"; } + /** * testNum2Alpha * @@ -535,6 +536,10 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $input='This is a text with html comments '; // we suppose this is not enough to be html content $after=dol_textishtml($input); $this->assertFalse($after); + + $input="A text\nwith a link https://aaa?param=abc&param2=def"; + $after=dol_textishtml($input); + $this->assertFalse($after); }