diff --git a/ChangeLog b/ChangeLog index 40cf93e9e3b..4ac20917630 100644 --- a/ChangeLog +++ b/ChangeLog @@ -55,7 +55,7 @@ Dolibarr better: - The deprecated way (with 4 parameters) to declare a new tab into a module descriptor file has been removed. You must now use the 6 parameters way. See file modMyModule.class.php for example. - Remove the javascrit function ac_delay() that is not used anymore by core code. -- Properties dictionnaries into module descriptor files has been renamed into dictionaries. +- Properties "dictionnaries" into module descriptor files has been renamed into "dictionaries". @@ -86,6 +86,8 @@ Fix: [ bug #1250 ] "Supplier Ref. product" sidebar search box does not work Fix: Bad space in predefined messages. Fix: Signature was not added for email sent from thirdparty page. Fix: Action event SHIPPING_VALIDATE is not implemented +Fix: The customer code was set to uppercase when using numbering module leopard. We + must keep data safe of any change. ***** ChangeLog for 3.5 compared to 3.4.* ***** For users: diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 9d85b9a1223..db9a12669cc 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -107,7 +107,7 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action // hooks include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once - + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { @@ -124,7 +124,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') { } } } -} +} // Delete proposal else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) { @@ -136,7 +136,7 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop $langs->load("errors"); setEventMessage($langs->trans($object->error), 'errors'); } -} +} // Remove line else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) { @@ -144,7 +144,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> // reorder lines if ($result) $object->line_order(true); - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -156,10 +156,10 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + header('Location: ' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id); exit(); -} +} // Validation else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) { @@ -180,16 +180,16 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr $langs->load("errors"); setEventMessage($langs->trans($object->error), 'errors'); } -} +} else if ($action == 'setdate' && $user->rights->propal->creer) { $datep = dol_mktime(12, 0, 0, $_POST ['remonth'], $_POST ['reday'], $_POST ['reyear']); - + if (empty($datep)) { $error ++; setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); } - + if (! $error) { $result = $object->set_date($user, $datep); if ($result < 0) @@ -203,22 +203,22 @@ else if ($action == 'setdate' && $user->rights->propal->creer) { $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST ['liv_month'], $_POST ['liv_day'], $_POST ['liv_year'])); if ($result < 0) dol_print_error($db, $object->error); -} +} // Positionne ref client else if ($action == 'set_ref_client' && $user->rights->propal->creer) { $object->set_ref_client($user, $_POST ['ref_client']); -} +} // Create proposal else if ($action == 'add' && $user->rights->propal->creer) { $object->socid = $socid; $object->fetch_thirdparty(); - + $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); $duration = GETPOST('duree_validite'); - + if (empty($datep)) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); $action = 'create'; @@ -229,16 +229,16 @@ else if ($action == 'add' && $user->rights->propal->creer) { $action = 'create'; $error ++; } - + if ($socid < 1) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); $action = 'create'; $error ++; } - + if (! $error) { $db->begin(); - + // Si on a selectionne une propal a copier, on realise la copie if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal')) { if ($object->fetch(GETPOST('copie_propal')) > 0) { @@ -260,7 +260,7 @@ else if ($action == 'add' && $user->rights->propal->creer) { $object->author = $user->id; // deprecated $object->note = GETPOST('note'); $object->statut = 0; - + $id = $object->create_from($user); } else { setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); @@ -276,16 +276,16 @@ else if ($action == 'add' && $user->rights->propal->creer) { $object->duree_validite = GETPOST('duree_validite'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); - + $object->contactid = GETPOST('contactidp'); $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note'); - + $object->origin = GETPOST('origin'); $object->origin_id = GETPOST('originid'); - + for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { if ($_POST ['idprod' . $i]) { $xid = 'idprod' . $i; @@ -294,7 +294,7 @@ else if ($action == 'add' && $user->rights->propal->creer) { $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); } } - + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) { @@ -302,10 +302,10 @@ else if ($action == 'add' && $user->rights->propal->creer) { $action = 'create'; } } - + if (! $error) { $id = $object->create($user); - + if ($id > 0) { // Insertion contact par defaut si defini if (GETPOST('contactidp') > 0) { @@ -315,10 +315,10 @@ else if ($action == 'add' && $user->rights->propal->creer) { setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); } } - + if (! $error) { $db->commit(); - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -330,7 +330,7 @@ else if ($action == 'add' && $user->rights->propal->creer) { $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + header('Location: ' . $_SERVER ["PHP_SELF"] . '?id=' . $id); exit(); } else { @@ -343,12 +343,12 @@ else if ($action == 'add' && $user->rights->propal->creer) { } } } -} +} // Classify billed else if ($action == 'classifybilled' && $user->rights->propal->cloturer) { $object->cloture($user, 4, ''); -} +} // Reopen proposal else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { @@ -356,7 +356,7 @@ else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GET if ($object->statut == 2 || $object->statut == 3) { $object->reopen($user, 1); } -} +} // Close proposal else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { @@ -374,11 +374,11 @@ else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST( // Add file in email form if (GETPOST('addfile')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + // Set tmp user directory TODO Use a dedicated directory for temp mails files $vardir = $conf->user->dir_output . "/" . $user->id; $upload_dir_tmp = $vardir . '/temp'; - + dol_add_file_process($upload_dir_tmp, 0, 0); $action = 'presend'; } @@ -386,11 +386,11 @@ if (GETPOST('addfile')) { // Remove file in email form if (GETPOST('removedfile')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + // Set tmp user directory $vardir = $conf->user->dir_output . "/" . $user->id; $upload_dir_tmp = $vardir . '/temp'; - + // TODO Delete only files that was uploaded from email form dol_remove_file_process($_POST ['removedfile'], 0); $action = 'presend'; @@ -401,7 +401,7 @@ if (GETPOST('removedfile')) { */ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { $langs->load('mails'); - + if ($object->id > 0) { if ($_POST ['sendto']) { // Le destinataire a ete fourni via le champ libre @@ -419,16 +419,16 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $sendtoid = $_POST ['receiver']; } } - + if (dol_strlen($sendto)) { $langs->load("commercial"); - + $from = $_POST ['fromname'] . ' <' . $_POST ['frommail'] . '>'; $replyto = $_POST ['replytoname'] . ' <' . $_POST ['replytomail'] . '>'; $message = $_POST ['message']; $sendtocc = $_POST ['sendtocc']; $deliveryreceipt = $_POST ['deliveryreceipt']; - + if (dol_strlen($_POST ['subject'])) $subject = $_POST ['subject']; else @@ -441,16 +441,16 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $actionmsg .= $message; } $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); - + // Create form object include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - + $attachedfiles = $formmail->get_attached_files(); $filepath = $attachedfiles ['paths']; $filename = $attachedfiles ['names']; $mimetype = $attachedfiles ['mimes']; - + // Envoi de la propal require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); @@ -466,7 +466,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $object->actionmsg2 = $actionmsg2; $object->fk_element = $object->id; $object->elementtype = $object->element; - + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($db); @@ -476,7 +476,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $this->errors = $interface->errors; } // Fin appel triggers - + if (! $error) { // Redirect here // This avoid sending mail twice if going out and then back to page @@ -513,7 +513,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G // Go back to draft if ($action == 'modif' && $user->rights->propal->creer) { $object->set_draft($user); - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -525,7 +525,7 @@ if ($action == 'modif' && $user->rights->propal->creer) { $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } -} +} else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { if ($_POST ["remise_id"]) { @@ -536,22 +536,28 @@ else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { } } } -} +} // Add line else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->propal->creer) { // Set if we used free entry or predefined product - if (GETPOST('addline_libre')) { - $predef = ''; - $idprod = 0; - $product_desc = (GETPOST('dp_desc') ? GETPOST('dp_desc') : ''); + if (GETPOST('addline_libre') + || (GETPOST('dp_desc') && ! GETPOST('addline_libre') && ! GETPOST('idprod', 'int')>0) // we push enter onto qty field + ) + { + $predef=''; + $idprod=0; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } - if (GETPOST('addline_predefined')) { - $predef = (($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); - $idprod = GETPOST('idprod', 'int'); - $product_desc = (GETPOST('product_desc') ? GETPOST('product_desc') : (GETPOST('np_desc') ? GETPOST('np_desc') : '')); + if (GETPOST('addline_predefined') + || (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field + ) + { + $predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); + $idprod=GETPOST('idprod', 'int'); + $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):'')); $price_ht = ''; $tva_tx = ''; } @@ -563,7 +569,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- } $qty = GETPOST('qty' . $predef); $remise_percent = GETPOST('remise_percent' . $predef); - + // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); @@ -575,12 +581,12 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- unset($_POST ["options_" . $key]); } } - + if (empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); $error ++; } - + if ((empty($idprod) || GETPOST('usenewaddlineform')) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for // proposal. { @@ -591,24 +597,24 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); $error ++; } - + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { $pu_ht = 0; $pu_ttc = 0; $price_min = 0; $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); - + $db->begin(); - + // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit if (! empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); - + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - + // If prices fields are update if (GETPOST('usenewaddlineform')) { $pu_ht = price2num($price_ht, 'MU'); @@ -619,7 +625,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- } else { $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); - + // On defini prix unitaire if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) { $pu_ht = $prod->multiprices [$object->client->price_level]; @@ -628,11 +634,11 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $price_base_type = $prod->multiprices_base_type [$object->client->price_level]; } elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - + $prodcustprice = new Productcustomerprice($db); - + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->client->id); - + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { if (count($prodcustprice->lines) > 0) { @@ -649,12 +655,12 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; } - + // if price ht is forced (ie: calculated by margin rate and cost price) if (! empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). @@ -665,9 +671,9 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); } } - + $desc = ''; - + // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; @@ -680,14 +686,14 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; } else { $desc = $prod->description; } - + $desc = dol_concatdesc($desc, $product_desc); - + // Add custom code and origin country into description if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { $tmptxt = '('; @@ -701,7 +707,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $desc = dol_concatdesc($desc, $tmptxt); } } - + $type = $prod->type; } else { $pu_ht = price2num($price_ht, 'MU'); @@ -712,32 +718,32 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $desc = $product_desc; $type = GETPOST('type'); } - + // Margin $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - + $date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - + // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->client); $localtax2_tx = get_localtax($tva_tx, 2, $object->client); - + $info_bits = 0; if ($tva_npr) $info_bits |= 0x01; - + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessage($mesg, 'errors'); } else { // Insert line $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_option); - + if ($result > 0) { $db->commit(); - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -749,7 +755,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + unset($_POST ['qty']); unset($_POST ['type']); unset($_POST ['remise_percent']); @@ -764,7 +770,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- unset($_POST ['np_marginRate']); unset($_POST ['np_markRate']); unset($_POST ['dp_desc']); - + unset($_POST ['idprod']); unset($_POST ['qty_predef']); unset($_POST ['remise_percent_predef']); @@ -775,12 +781,12 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- unset($_POST ['np_desc']); } else { $db->rollback(); - + setEventMessage($object->error, 'errors'); } } } -} +} // Mise a jour d'une ligne dans la propale else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) { @@ -788,24 +794,24 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $info_bits = 0; if (preg_match('/\*/', GETPOST('tva_tx'))) $info_bits |= 0x01; - + // Clean parameters $description = dol_htmlcleanlastbr(GETPOST('product_desc')); - + // Define vat_rate $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $vat_rate = str_replace('*', '', $vat_rate); $localtax1_rate = get_localtax($vat_rate, 1, $object->client); $localtax2_rate = get_localtax($vat_rate, 2, $object->client); $pu_ht = GETPOST('price_ht'); - + // Add buying price $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); - + $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - + // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); @@ -817,26 +823,26 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa unset($_POST ["options_" . $key]); } } - + // Define special_code for special lines $special_code = 0; if (! GETPOST('qty')) $special_code = 3; - + // Check minimum price $productid = GETPOST('productid', 'int'); if (! empty($productid)) { $product = new Product($db); $res = $product->fetch($productid); - + $type = $product->type; - + $price_min = $product->price_min; if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) $price_min = $product->multiprices_min [$object->client->price_level]; - + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - + if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); $error ++; @@ -844,22 +850,22 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa } else { $type = GETPOST('type'); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - + // Check parameters if (GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); $error ++; } } - + if (! $error) { $db->begin(); - + $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_option); - + if ($result >= 0) { $db->commit(); - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -871,7 +877,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + unset($_POST ['qty']); unset($_POST ['type']); unset($_POST ['productid']); @@ -886,23 +892,23 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa unset($_POST ['buying_price']); } else { $db->rollback(); - + setEventMessage($object->error, 'errors'); } } -} +} else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) { header('Location: ' . $_SERVER ['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition exit(); -} +} // Generation doc (depuis lien ou depuis cartouche doc) else if ($action == 'builddoc' && $user->rights->propal->creer) { if (GETPOST('model')) { $object->setDocModel($user, GETPOST('model')); } - + // Define output language $outputlangs = $langs; if (! empty($conf->global->MAIN_MULTILANGS)) { @@ -912,7 +918,7 @@ else if ($action == 'builddoc' && $user->rights->propal->creer) { } $ret = $object->fetch($id); // Reload to get new records $result = propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - + if ($result <= 0) { dol_print_error($db, $result); exit(); @@ -920,13 +926,13 @@ else if ($action == 'builddoc' && $user->rights->propal->creer) { header('Location: ' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); exit(); } -} +} // Remove file in doc form else if ($action == 'remove_file' && $user->rights->propal->creer) { if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + $langs->load("other"); $upload_dir = $conf->propal->dir_output; $file = $upload_dir . '/' . GETPOST('file'); @@ -936,40 +942,40 @@ else if ($action == 'remove_file' && $user->rights->propal->creer) { else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); } -} +} // Set project else if ($action == 'classin' && $user->rights->propal->creer) { $object->setProject($_POST ['projectid']); -} +} // Delai de livraison else if ($action == 'setavailability' && $user->rights->propal->creer) { $result = $object->availability($_POST ['availability_id']); -} +} // Origine de la propale else if ($action == 'setdemandreason' && $user->rights->propal->creer) { $result = $object->demand_reason($_POST ['demand_reason_id']); -} +} // Conditions de reglement else if ($action == 'setconditions' && $user->rights->propal->creer) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); -} +} else if ($action == 'setremisepercent' && $user->rights->propal->creer) { $result = $object->set_remise_percent($user, $_POST ['remise_percent']); -} +} else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) { $result = $object->set_remise_absolue($user, $_POST ['remise_absolue']); -} +} // Mode de reglement else if ($action == 'setmode' && $user->rights->propal->creer) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); -} +} /* * Ordonnancement des lignes @@ -977,7 +983,7 @@ else if ($action == 'setmode' && $user->rights->propal->creer) { else if ($action == 'up' && $user->rights->propal->creer) { $object->line_up(GETPOST('rowid')); - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -989,14 +995,14 @@ else if ($action == 'up' && $user->rights->propal->creer) { $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + header('Location: ' . $_SERVER ["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); exit(); -} +} else if ($action == 'down' && $user->rights->propal->creer) { $object->line_down(GETPOST('rowid')); - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -1008,7 +1014,7 @@ else if ($action == 'down' && $user->rights->propal->creer) { $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + header('Location: ' . $_SERVER ["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); exit(); } else if ($action == 'update_extras') { @@ -1017,7 +1023,7 @@ else if ($action == 'down' && $user->rights->propal->creer) { $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error ++; - + if (! $error) { // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! @@ -1034,7 +1040,7 @@ else if ($action == 'down' && $user->rights->propal->creer) { } else if ($reshook < 0) $error ++; } - + if ($error) $action = 'edit_extras'; } @@ -1045,7 +1051,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal-> $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $result = $object->add_contact($contactid, $_POST ["type"], $_POST ["source"]); } - + if ($result >= 0) { header("Location: " . $_SERVER ['PHP_SELF'] . "?id=" . $object->id); exit(); @@ -1057,7 +1063,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal-> setEventMessage($object->error, 'errors'); } } - } + } // Bascule du statut d'un contact else if ($action == 'swapstatut') { @@ -1066,13 +1072,13 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal-> } else { dol_print_error($db); } - } + } // Efface un contact else if ($action == 'deletecontact') { $object->fetch($id); $result = $object->delete_contact($lineid); - + if ($result >= 0) { header("Location: " . $_SERVER ['PHP_SELF'] . "?id=" . $object->id); exit(); @@ -1099,32 +1105,32 @@ $now = dol_now(); // Add new proposal if ($action == 'create') { print_fiche_titre($langs->trans("NewProp")); - + $soc = new Societe($db); if ($socid > 0) $res = $soc->fetch($socid); - + $object = new Propal($db); - + print '
'; print ''; print ''; - + if ($origin != 'project' && $originid) { print ''; print ''; } - + print ''; - + // Reference print ''; - + // Ref customer print ''; print ''; - + // Third party print ''; print ''; @@ -1139,13 +1145,13 @@ if ($action == 'create') { print ''; } print '' . "\n"; - + // Contacts if ($socid > 0) { print "'; - + // Ligne info remises tiers print ''; } - + // Date print ''; - + // Validaty duration print ''; - + // Terms of payment print ''; - + // Mode of payment print ''; - + // What trigger creation print ''; - + // Delivery delay print ''; - + // Delivery date (or manufacturing) print ''; print ''; - + // Model print ''; print ''; @@ -1212,19 +1218,19 @@ if ($action == 'create') { $liste = ModelePDFPropales::liste_modeles($db); print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); print ""; - + // Project if (! empty($conf->projet->enabled) && $socid > 0) { - + $formproject = new FormProjets($db); - + $projectid = 0; if ($origin == 'project') $projectid = ($originid ? $originid : 0); - + print ''; print ''; print ''; } - + // Other attributes $parameters = array('colspan' => ' colspan="3"'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified @@ -1242,18 +1248,18 @@ if ($action == 'create') { if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } - + print "
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; print '
' . $langs->trans('Customer') . '
" . $langs->trans("DefaultContact") . ''; $form->select_contacts($soc->id, $setcontact, 'contactidp', 1, $srccontactslist); print '
' . $langs->trans('Discounts') . ''; if ($soc->remise_percent) @@ -1161,35 +1167,35 @@ if ($action == 'create') { print '.'; print '
' . $langs->trans('Date') . ''; $form->select_date('', '', '', '', '', "addprop"); print '
' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . '
' . $langs->trans('PaymentConditionsShort') . ''; $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id'); print '
' . $langs->trans('PaymentMode') . ''; $form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id'); print '
' . $langs->trans('Source') . ''; $form->select_demand_reason('', 'demand_reason_id', "SRC_PROP", 1); print '
' . $langs->trans('AvailabilityPeriod') . ''; $form->select_availability('', 'availability_id', '', 1); print '
' . $langs->trans("DeliveryDate") . ''; @@ -1204,7 +1210,7 @@ if ($action == 'create') { $form->select_date($datepropal, 'liv_', '', '', '', "addprop"); } print '
' . $langs->trans("DefaultModel") . '
' . $langs->trans("Project") . ''; - + $numprojet = $formproject->select_projects($soc->id, $projectid); if ($numprojet == 0) { $langs->load("projects"); @@ -1233,7 +1239,7 @@ if ($action == 'create') { print '
"; print '
'; - + /* * Combobox pour la fonction de copie */ - + if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) { print ''; } - + print ''; if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) { // For backward compatibility @@ -1263,7 +1269,7 @@ if ($action == 'create') { print ''; - + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print ''; - + print ''; print ''; } - + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) { print ''; } print '
'; $liste_propal = array(); $liste_propal [0] = ''; - + $sql = "SELECT p.rowid as id, p.ref, s.nom"; $sql .= " FROM " . MAIN_DB_PREFIX . "propal p"; $sql .= ", " . MAIN_DB_PREFIX . "societe s"; @@ -1271,7 +1277,7 @@ if ($action == 'create') { $sql .= " AND p.entity = " . $conf->entity; $sql .= " AND p.fk_statut <> 0"; $sql .= " ORDER BY Id"; - + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1287,19 +1293,19 @@ if ($action == 'create') { dol_print_error($db); } print '
 
' . $langs->trans("CreateEmptyPropal") . '
'; if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $lib = $langs->trans("ProductsAndServices"); - + print ''; print ''; print ''; @@ -1318,34 +1324,34 @@ if ($action == 'create') { print ''; print ''; } - + print "
' . $lib . '%
"; } print '
'; print '
'; - + $langs->load("bills"); print '
'; print ''; print ' '; print '
'; - + print "
"; } else { /* * Show object in view mode */ - + $soc = new Societe($db); $soc->fetch($object->socid); - + $head = propal_prepare_head($object); dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal'); - + $formconfirm = ''; - + // Clone confirmation if ($action == 'clone') { // Create an array for form @@ -1357,27 +1363,27 @@ if ($action == 'create') { array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ClonePropal'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } + } // Confirm delete else if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); - } + } // Confirm reopen else if ($action == 'reopen') { $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp', $object->ref), 'confirm_reopen', '', 0, 1); - } + } // Confirmation delete product/service line else if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); - } + } // Confirm validate proposal else if ($action == 'validate') { $error = 0; - + // on verifie si l'objet est en numerotation provisoire $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { @@ -1389,7 +1395,7 @@ if ($action == 'create') { } else { $numref = $object->ref; } - + $text = $langs->trans('ConfirmValidateProp', $numref); if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; @@ -1397,30 +1403,30 @@ if ($action == 'create') { $text .= '
'; $text .= $notify->confirmMessage('PROPAL_VALIDATE', $object->socid); } - + if (! $error) $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); } - + if (! $formconfirm) { $parameters = array('lineid' => $lineid); $formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified // by // hook } - + // Print form confirm print $formconfirm; - + print ''; - + $linkback = '' . $langs->trans("BackToList") . ''; - + // Ref print ''; - + // Ref customer print '
' . $langs->trans('Ref') . ''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '
'; print ''; print ''; - + // Company print ''; print ''; - + // Ligne info remises tiers print ''; - + // Date of proposal print ''; print ''; - + // Date end proposal print ''; print ''; print ''; - + // Payment term print '
'; @@ -1442,11 +1448,11 @@ if ($action == 'create') { } print '
' . $langs->trans('Company') . '' . $soc->getNomUrl(1) . '
' . $langs->trans('Discounts') . ''; if ($soc->remise_percent) @@ -1474,7 +1480,7 @@ if ($action == 'create') { if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.'; print '
'; @@ -1500,7 +1506,7 @@ if ($action == 'create') { } } print '
'; @@ -1529,7 +1535,7 @@ if ($action == 'create') { } print '
'; print ''; print ''; - + // Delivery date $langs->load('deliveries'); print ''; print ''; - + // Delivery delay print '
'; @@ -1546,7 +1552,7 @@ if ($action == 'create') { } print '
'; @@ -1569,7 +1575,7 @@ if ($action == 'create') { } print '
'; print ''; print ''; - + // Origin of demand print ''; $form_close .= '
'; @@ -1586,10 +1592,10 @@ if ($action == 'create') { } else { $form->form_availability($_SERVER ['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1); } - + print '
'; print ''; print ''; - + // Payment mode print ''; print ''; - + // Project if (! empty($conf->projet->enabled)) { $langs->load("projects"); @@ -1659,7 +1665,7 @@ if ($action == 'create') { } print ''; } - + if ($soc->outstanding_limit) { // Outstanding Bill print ''; print ''; } - + // Other attributes (TODO Move this into an include) $res = $object->fetch_optionals($object->id, $extralabels); $parameters = array('colspan' => ' colspan="3"'); @@ -1695,18 +1701,18 @@ if ($action == 'create') { if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) { $value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); } - + if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key) { print ''; print ''; print ''; print ''; print ''; - + print $extrafields->showInputField($key, $value); - + print ''; - + print ''; } else { print $extrafields->showOutputField($key, $value); @@ -1717,12 +1723,12 @@ if ($action == 'create') { } } } - + // Amount HT print ''; print ''; print ''; - + // Margin Infos if (! empty($conf->margin->enabled)) { print ''; } print ''; - + // Amount VAT print ''; print ''; print ''; - + // Amount Local Taxes if ($mysoc->localtax1_assuj == "1") // Localtax1 { @@ -1749,84 +1755,84 @@ if ($action == 'create') { print ''; print ''; } - + // Amount TTC print ''; print ''; print ''; - + // Statut print ''; - + print '
'; @@ -1605,10 +1611,10 @@ if ($action == 'create') { } else { $form->form_demand_reason($_SERVER ['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none'); } - + print '
'; @@ -1625,7 +1631,7 @@ if ($action == 'create') { $form->form_modes_reglement($_SERVER ['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); } print '
'; @@ -1670,7 +1676,7 @@ if ($action == 'create') { print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; @@ -1730,12 +1736,12 @@ if ($action == 'create') { print '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '

'; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; } - + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; } - + /* * Lines */ - + // Show object lines $result = $object->getLinesArray(); - + print '
'; - + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } - + print ''; - + if (! empty($object->lines)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); - + // Form to add new line if ($object->statut == 0 && $user->rights->propal->creer) { if ($action != 'editline') { $var = true; - + if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services $object->formAddObjectLine(1, $mysoc, $soc); } else { // Add free products/services $object->formAddFreeProduct(1, $mysoc, $soc); - + // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var = ! $var; $object->formAddPredefinedProduct(1, $mysoc, $soc); } } - + $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been // modified // by hook } } - + print '
'; - + print "
\n"; - + dol_fiche_end(); - + if ($action == 'statut') { /* * Formulaire cloture (signe ou non) @@ -1851,16 +1857,16 @@ if ($action == 'create') { $form_close .= ' '; $form_close .= '
'; - + print $form_close; } - + /* * Boutons Actions */ if ($action != 'presend') { print '
'; - + $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook @@ -1884,13 +1890,13 @@ if ($action == 'create') { if ($object->statut == 1 && $user->rights->propal->creer) { print ''; } - + // ReOpen if (($object->statut == 2 || $object->statut == 3) && $user->rights->propal->cloturer) { print ''; } - + // Send if ($object->statut == 1 || $object->statut == 2) { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) { @@ -1898,46 +1904,46 @@ if ($action == 'create') { } else print ''; } - + // Create an order if (! empty($conf->commande->enabled) && $object->statut == 2) { if ($user->rights->commande->creer) { print ''; } } - + // Create contract if ($conf->contrat->enabled && $object->statut == 2) { $langs->load("contracts"); - + if ($user->rights->contrat->creer) { print ''; } } - + // Create an invoice and classify billed if ($object->statut == 2) { if (! empty($conf->facture->enabled) && $user->rights->facture->creer) { print ''; } - + $arraypropal = $object->getInvoiceArrayList(); if (is_array($arraypropal) && count($arraypropal) > 0) { print ''; } } - + // Close if ($object->statut == 1 && $user->rights->propal->cloturer) { print ''; } - + // Clone if ($user->rights->propal->creer) { print ''; } - + // Delete if ($user->rights->propal->supprimer) { print ''; } - + /* * Action presend * @@ -1994,7 +2000,7 @@ if ($action == 'create') { include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/')); $file = $fileparams ['fullname']; - + // Build document if it not exists if (! $file || ! is_readable($file)) { // Define output language @@ -2008,7 +2014,7 @@ if ($action == 'create') { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $result = propale_pdf_create($db, $object, GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db, $result); @@ -2017,10 +2023,10 @@ if ($action == 'create') { $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/')); $file = $fileparams ['fullname']; } - + print '
'; print_titre($langs->trans('SendPropalByMail')); - + // Create form object include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -2044,19 +2050,19 @@ if ($action == 'create') { $formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; - + // Tableau des substitutions $formmail->substit ['__PROPREF__'] = $object->ref; $formmail->substit ['__SIGNATURE__'] = $user->signature; $formmail->substit ['__REFCLIENT__'] = $object->ref_client; $formmail->substit ['__PERSONALIZED__'] = ''; $formmail->substit ['__CONTACTCIVNAME__'] = ''; - + // Find the good contact adress $custcontact = ''; $contactarr = array(); $contactarr = $object->liste_contact(- 1, 'external'); - + if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { if ($contact ['libelle'] == $langs->trans('TypeContact_propal_external_CUSTOMER')) { @@ -2065,12 +2071,12 @@ if ($action == 'create') { $custcontact = $contactstatic->getFullName($langs, 1); } } - + if (! empty($custcontact)) { $formmail->substit ['__CONTACTCIVNAME__'] = $custcontact; } } - + // Tableau des parametres complementaires $formmail->param ['action'] = 'send'; $formmail->param ['models'] = 'propal_send'; @@ -2081,9 +2087,9 @@ if ($action == 'create') { $formmail->clear_attached_files(); $formmail->add_attached_files($file, basename($file), dol_mimetype($file)); } - + print $formmail->get_form(); - + print '
'; } } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 1a209234612..58a650b72c7 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -102,7 +102,7 @@ $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once - + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) { if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { @@ -119,7 +119,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande-> } } } -} +} // Reopen a closed order else if ($action == 'reopen' && $user->rights->commande->creer) { @@ -132,7 +132,7 @@ else if ($action == 'reopen' && $user->rights->commande->creer) { $mesg = '
' . $object->error . '
'; } } -} +} // Suppression de la commande else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) { @@ -143,7 +143,7 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->comm } else { $mesg = '
' . $object->error . '
'; } -} +} // Remove a product line else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) { @@ -164,42 +164,42 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> $ret = $object->fetch($object->id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + header('Location: ' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id); exit(); } else { $mesg = '
' . $object->error . '
'; } -} +} // Categorisation dans projet else if ($action == 'classin' && $user->rights->commande->creer) { $object->setProject(GETPOST('projectid')); -} +} // Add order else if ($action == 'add' && $user->rights->commande->creer) { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - + if ($datecommande == '') { $mesg = '
' . $langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')) . '
'; $action = 'create'; $error ++; } - + if ($socid < 1) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); $action = 'create'; $error ++; } - + if (! $error) { $object->socid = $socid; $object->fetch_thirdparty(); - + $db->begin(); - + $object->date_commande = $datecommande; $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); @@ -214,7 +214,7 @@ else if ($action == 'add' && $user->rights->commande->creer) { $object->date_livraison = $datelivraison; $object->fk_delivery_address = GETPOST('fk_address'); $object->contactid = GETPOST('contactidp'); - + // If creation from another object of another module (Example: origin=propal, originid=1) if (! empty($origin) && ! empty($originid)) { // Parse element/subelement (ex: project_task) @@ -223,7 +223,7 @@ else if ($action == 'add' && $user->rights->commande->creer) { $element = $regs [1]; $subelement = $regs [2]; } - + // For compatibility if ($element == 'order') { $element = $subelement = 'commande'; @@ -235,46 +235,46 @@ else if ($action == 'add' && $user->rights->commande->creer) { if ($element == 'contract') { $element = $subelement = 'contrat'; } - + $object->origin = $origin; $object->origin_id = $originid; - + // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; $other_linked_objects = GETPOST('other_linked_objects', 'array'); if (! empty($other_linked_objects)) { $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); } - + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) $error ++; - + if (! $error) { $object_id = $object->create($user); - + if ($object_id > 0) { dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - + $classname = ucfirst($subelement); $srcobject = new $classname($db); - + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) { $lines = $srcobject->lines; if (empty($lines) && method_exists($srcobject, 'fetch_lines')) $lines = $srcobject->fetch_lines(); - + $fk_parent_line = 0; $num = count($lines); - + for($i = 0; $i < $num; $i ++) { $label = (! empty($lines [$i]->label) ? $lines [$i]->label : ''); $desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle); $product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0); - + // Dates // TODO mutualiser $date_start = $lines [$i]->date_debut_prevue; @@ -287,12 +287,12 @@ else if ($action == 'add' && $user->rights->commande->creer) { $date_end = $lines [$i]->date_fin_reel; if ($lines [$i]->date_end) $date_end = $lines [$i]->date_end; - + // Reset fk_parent_line for no child products and special product if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { $fk_parent_line = 0; } - + // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) // For avoid conflicts if // trigger used @@ -300,20 +300,20 @@ else if ($action == 'add' && $user->rights->commande->creer) { $lines [$i]->fetch_optionals($lines [$i]->rowid); $array_option = $lines [$i]->array_options; } - + $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); - + if ($result < 0) { $error ++; break; } - + // Defined the new fk_parent_line if ($result > 0 && $lines [$i]->product_type == 9) { $fk_parent_line = $result; } } - + // Hooks $parameters = array('objFrom' => $srcobject); $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been @@ -337,10 +337,10 @@ else if ($action == 'add' && $user->rights->commande->creer) { $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) $error ++; - + if (! $error) { $object_id = $object->create($user); - + // If some invoice's lines already known $NBLINES = 8; for($i = 1; $i <= $NBLINES; $i ++) { @@ -353,7 +353,7 @@ else if ($action == 'add' && $user->rights->commande->creer) { } } } - + // Insert default contacts if defined if ($object_id > 0) { if (GETPOST('contactidp')) { @@ -363,11 +363,11 @@ else if ($action == 'add' && $user->rights->commande->creer) { $error ++; } } - + $id = $object_id; $action = ''; } - + // End of object creation, we show it if ($object_id > 0 && ! $error) { $db->commit(); @@ -380,20 +380,20 @@ else if ($action == 'add' && $user->rights->commande->creer) { $mesg = '
' . $object->error . '
'; } } -} +} else if ($action == 'classifybilled' && $user->rights->commande->creer) { $ret = $object->classifyBilled(); -} +} // Positionne ref commande client else if ($action == 'set_ref_client' && $user->rights->commande->creer) { $object->set_ref_client($user, GETPOST('ref_client')); -} +} else if ($action == 'setremise' && $user->rights->commande->creer) { $object->set_remise($user, GETPOST('remise')); -} +} else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { if (GETPOST('remise_id')) { @@ -403,45 +403,45 @@ else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { dol_print_error($db, $object->error); } } -} +} else if ($action == 'setdate' && $user->rights->commande->creer) { // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); - + $result = $object->set_date($user, $date); if ($result < 0) { $mesg = '
' . $object->error . '
'; } -} +} else if ($action == 'setdate_livraison' && $user->rights->commande->creer) { // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - + $result = $object->set_date_livraison($user, $datelivraison); if ($result < 0) { $mesg = '
' . $object->error . '
'; } -} +} else if ($action == 'setmode' && $user->rights->commande->creer) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) dol_print_error($db, $object->error); -} +} else if ($action == 'setavailability' && $user->rights->commande->creer) { $result = $object->availability(GETPOST('availability_id')); if ($result < 0) dol_print_error($db, $object->error); -} +} else if ($action == 'setdemandreason' && $user->rights->commande->creer) { $result = $object->demand_reason(GETPOST('demand_reason_id')); if ($result < 0) dol_print_error($db, $object->error); -} +} else if ($action == 'setconditions' && $user->rights->commande->creer) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); @@ -458,38 +458,44 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $ret = $object->fetch($object->id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } -} +} else if ($action == 'setremisepercent' && $user->rights->commande->creer) { $result = $object->set_remise($user, GETPOST('remise_percent')); -} +} else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) { $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); -} +} // Add a new line else if ($action == 'addline' && $user->rights->commande->creer) { $langs->load('errors'); $error = false; - + // Set if we used free entry or predefined product - if (GETPOST('addline_libre')) { - $predef = ''; - $idprod = 0; - $product_desc = (GETPOST('dp_desc') ? GETPOST('dp_desc') : ''); + if (GETPOST('addline_libre') + || (GETPOST('dp_desc') && ! GETPOST('addline_libre') && ! GETPOST('idprod', 'int')>0) // we push enter onto qty field + ) + { + $predef=''; + $idprod=0; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } - if (GETPOST('addline_predefined')) { - $predef = (($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); - $idprod = GETPOST('idprod', 'int'); - $product_desc = (GETPOST('product_desc') ? GETPOST('product_desc') : (GETPOST('np_desc') ? GETPOST('np_desc') : '')); + if (GETPOST('addline_predefined') + || (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field + ) + { + $predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); + $idprod=GETPOST('idprod', 'int'); + $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):'')); $price_ht = ''; $tva_tx = ''; } @@ -501,7 +507,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { } $qty = GETPOST('qty' . $predef); $remise_percent = GETPOST('remise_percent' . $predef); - + // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); @@ -513,7 +519,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { unset($_POST ["options_" . $key]); } } - + if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); $error ++; @@ -535,13 +541,13 @@ else if ($action == 'addline' && $user->rights->commande->creer) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); $error ++; } - + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { // Clean parameters $date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); - + // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit @@ -549,9 +555,9 @@ else if ($action == 'addline' && $user->rights->commande->creer) { if (! empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); - + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - + // Update if prices fields are defined if (GETPOST('usenewaddlineform')) { $pu_ht = price2num($price_ht, 'MU'); @@ -562,7 +568,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { } else { $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); - + // multiprix if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) { $pu_ht = $prod->multiprices [$object->client->price_level]; @@ -571,11 +577,11 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $price_base_type = $prod->multiprices_base_type [$object->client->price_level]; } elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - + $prodcustprice = new Productcustomerprice($db); - + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->client->id); - + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { if (count($prodcustprice->lines) > 0) { @@ -592,12 +598,12 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; } - + // if price ht is forced (ie: calculated by margin rate and cost price) if (! empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). @@ -608,9 +614,9 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); } } - + $desc = ''; - + // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; @@ -623,14 +629,14 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; } else { $desc = $prod->description; } - + $desc = dol_concatdesc($desc, $product_desc); - + // Add custom code and origin country into description if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { $tmptxt = '('; @@ -644,7 +650,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $desc = dol_concatdesc($desc, $tmptxt); } } - + $type = $prod->type; } else { $pu_ht = price2num($price_ht, 'MU'); @@ -655,31 +661,31 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $desc = $product_desc; $type = GETPOST('type'); } - + // Margin $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - + // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->client); $localtax2_tx = get_localtax($tva_tx, 2, $object->client); - + $desc = dol_htmlcleanlastbr($desc); - + $info_bits = 0; if ($tva_npr) $info_bits |= 0x01; - + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessage($mesg, 'errors'); } else { // Insert line $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); - + if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -690,10 +696,10 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + unset($_POST ['qty']); unset($_POST ['type']); unset($_POST ['remise_percent']); @@ -708,7 +714,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { unset($_POST ['np_marginRate']); unset($_POST ['np_markRate']); unset($_POST ['dp_desc']); - + unset($_POST ['idprod']); unset($_POST ['qty_predef']); unset($_POST ['remise_percent_predef']); @@ -722,7 +728,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { } } } -} +} /* * Mise a jour d'une ligne dans la commande @@ -736,21 +742,21 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $description = dol_htmlcleanlastbr(GETPOST('product_desc')); $pu_ht = GETPOST('price_ht'); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - + // Define info_bits $info_bits = 0; if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01; - + // Define vat_rate $vat_rate = str_replace('*', '', $vat_rate); $localtax1_rate = get_localtax($vat_rate, 1, $object->client); $localtax2_rate = get_localtax($vat_rate, 2, $object->client); - + // Add buying price $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); - + // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); @@ -761,21 +767,21 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' unset($_POST ["options_" . $key]); } } - + // Check minimum price $productid = GETPOST('productid', 'int'); if (! empty($productid)) { $product = new Product($db); $product->fetch($productid); - + $type = $product->type; - + $price_min = $product->price_min; if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) $price_min = $product->multiprices_min [$object->client->price_level]; - + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - + if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); $error ++; @@ -783,17 +789,17 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' } else { $type = GETPOST('type'); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - + // Check parameters if (GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); $error ++; } } - + if (! $error) { $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); - + if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -807,11 +813,11 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $ret = $object->fetch($object->id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + unset($_POST ['qty']); unset($_POST ['type']); unset($_POST ['productid']); @@ -828,16 +834,16 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' setEventMessage($object->error, 'errors'); } } -} +} else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('cancel') == $langs->trans('Cancel')) { header('Location: ' . $_SERVER ['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition exit(); -} +} else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { $idwarehouse = GETPOST('idwarehouse'); - + // Check parameters if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) { if (! $idwarehouse || $idwarehouse == - 1) { @@ -846,7 +852,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co $action = ''; } } - + if (! $error) { $result = $object->valid($user, $idwarehouse); if ($result >= 0) { @@ -865,12 +871,12 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } -} +} // Go back to draft status else if ($action == 'confirm_modif' && $user->rights->commande->creer) { $idwarehouse = GETPOST('idwarehouse'); - + // Check parameters if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) { if (! $idwarehouse || $idwarehouse == - 1) { @@ -879,7 +885,7 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) { $action = ''; } } - + if (! $error) { $result = $object->set_draft($user, $idwarehouse); if ($result >= 0) { @@ -900,17 +906,17 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) { } } } -} +} else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { $result = $object->cloture($user); if ($result < 0) $mesgs = $object->errors; -} +} else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { $idwarehouse = GETPOST('idwarehouse'); - + // Check parameters if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) { if (! $idwarehouse || $idwarehouse == - 1) { @@ -919,11 +925,11 @@ else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->comm $action = ''; } } - + if (! $error) { $result = $object->cancel($idwarehouse); } -} +} /* * Ordonnancement des lignes @@ -931,7 +937,7 @@ else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->comm else if ($action == 'up' && $user->rights->commande->creer) { $object->line_up(GETPOST('rowid')); - + // Define output language $outputlangs = $langs; $newlang = ''; @@ -943,17 +949,17 @@ else if ($action == 'up' && $user->rights->commande->creer) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - + header('Location: ' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); exit(); -} +} else if ($action == 'down' && $user->rights->commande->creer) { $object->line_down(GETPOST('rowid')); - + // Define output language $outputlangs = $langs; $newlang = ''; @@ -967,10 +973,10 @@ else if ($action == 'down' && $user->rights->commande->creer) { } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - + header('Location: ' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); exit(); -} +} else if ($action == 'builddoc') // In get or post { @@ -978,11 +984,11 @@ else if ($action == 'builddoc') // In get or post * Generate order document * define into /core/modules/commande/modules_commande.php */ - + // Save last template used to generate document if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha')); - + // Define output language $outputlangs = $langs; $newlang = ''; @@ -995,18 +1001,18 @@ else if ($action == 'builddoc') // In get or post $outputlangs->setDefaultLang($newlang); } $result = commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - + if ($result <= 0) { dol_print_error($db, $result); exit(); } -} +} // Remove file in doc form else if ($action == 'remove_file') { if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + $langs->load("other"); $upload_dir = $conf->commande->dir_output; $file = $upload_dir . '/' . GETPOST('file'); @@ -1017,7 +1023,7 @@ else if ($action == 'remove_file') { setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); $action = ''; } -} +} // Print file else if ($action == 'print_file' and $user->rights->printipp->read) { @@ -1026,7 +1032,7 @@ else if ($action == 'print_file' and $user->rights->printipp->read) { $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); $action = ''; -} +} else if ($action == 'update_extras') { // Fill array 'array_options' with data from update form @@ -1034,7 +1040,7 @@ else if ($action == 'update_extras') { $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error ++; - + if (! $error) { // Actions on extra fields (by external module or standard code) // FIXME le hook fait double emploi avec le trigger !! @@ -1050,7 +1056,7 @@ else if ($action == 'update_extras') { } else if ($reshook < 0) $error ++; } - + if ($error) $action = 'edit_extras'; } @@ -1060,11 +1066,11 @@ else if ($action == 'update_extras') { */ if (GETPOST('addfile')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + // Set tmp user directory TODO Use a dedicated directory for temp mails files $vardir = $conf->user->dir_output . "/" . $user->id; $upload_dir_tmp = $vardir . '/temp'; - + dol_add_file_process($upload_dir_tmp, 0, 0); $action = 'presend'; } @@ -1074,11 +1080,11 @@ if (GETPOST('addfile')) { */ if (GETPOST('removedfile')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + // Set tmp user directory $vardir = $conf->user->dir_output . "/" . $user->id; $upload_dir_tmp = $vardir . '/temp'; - + // TODO Delete only files that was uploaded from email form dol_remove_file_process(GETPOST('removedfile'), 0); $action = 'presend'; @@ -1089,11 +1095,11 @@ if (GETPOST('removedfile')) { */ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { $langs->load('mails'); - + if ($object->id > 0) { // $ref = dol_sanitizeFileName($object->ref); // $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - + // if (is_readable($file)) // { if (GETPOST('sendto')) { @@ -1112,16 +1118,16 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $sendtoid = GETPOST('receiver'); } } - + if (dol_strlen($sendto)) { $langs->load("commercial"); - + $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>'; $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>'; $message = GETPOST('message'); $sendtocc = GETPOST('sendtocc'); $deliveryreceipt = GETPOST('deliveryreceipt'); - + if ($action == 'send') { if (dol_strlen(GETPOST('subject'))) $subject = GETPOST('subject'); @@ -1136,16 +1142,16 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G } $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); } - + // Create form object include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - + $attachedfiles = $formmail->get_attached_files(); $filepath = $attachedfiles ['paths']; $filename = $attachedfiles ['names']; $mimetype = $attachedfiles ['mimes']; - + // Send mail require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); @@ -1156,9 +1162,9 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G if ($result) { $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); // Must not // contains " - + $error = 0; - + // Initialisation donnees $object->sendtoid = $sendtoid; $object->actiontypecode = $actiontypecode; @@ -1166,7 +1172,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $object->actionmsg2 = $actionmsg2; $object->fk_element = $object->id; $object->elementtype = $object->element; - + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($db); @@ -1176,7 +1182,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $this->errors = $interface->errors; } // Fin appel triggers - + if ($error) { dol_print_error($db); } else { @@ -1223,7 +1229,7 @@ if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->righ $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); } - + if ($result >= 0) { header("Location: " . $_SERVER ['PHP_SELF'] . "?id=" . $object->id); exit(); @@ -1235,7 +1241,7 @@ if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->righ $mesg = '
' . $object->error . '
'; } } - } + } // bascule du statut d'un contact else if ($action == 'swapstatut') { @@ -1244,12 +1250,12 @@ if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->righ } else { dol_print_error($db); } - } + } // Efface un contact else if ($action == 'deletecontact') { $result = $object->delete_contact($lineid); - + if ($result >= 0) { header("Location: " . $_SERVER ['PHP_SELF'] . "?id=" . $object->id); exit(); @@ -1278,13 +1284,13 @@ $formorder = new FormOrder($db); */ if ($action == 'create' && $user->rights->commande->creer) { print_fiche_titre($langs->trans('CreateOrder')); - + dol_htmloutput_mesg($mesg, $mesgs, 'error'); - + $soc = new Societe($db); if ($socid > 0) $res = $soc->fetch($socid); - + if (! empty($origin) && ! empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1292,7 +1298,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $element = $regs [1]; $subelement = $regs [2]; } - + if ($element == 'project') { $projectid = $originid; } else { @@ -1307,23 +1313,23 @@ if ($action == 'create' && $user->rights->commande->creer) { if ($element == 'contract') { $element = $subelement = 'contrat'; } - + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - + $classname = ucfirst($subelement); $objectsrc = new $classname($db); $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) $objectsrc->fetch_lines(); $objectsrc->fetch_thirdparty(); - + // Replicate extrafields $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; - + $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); - + $soc = $objectsrc->client; $cond_reglement_id = (! empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (! empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1)); $mode_reglement_id = (! empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (! empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); @@ -1332,12 +1338,12 @@ if ($action == 'create' && $user->rights->commande->creer) { $remise_percent = (! empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (! empty($soc->remise_percent) ? $soc->remise_percent : 0)); $remise_absolue = (! empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (! empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : 0; - + $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); - + $note_private = (! empty($objectsrc->note_private) ? $objectsrc->note_private : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); - + // Object source contacts list $srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1); } @@ -1352,9 +1358,9 @@ if ($action == 'create' && $user->rights->commande->creer) { $projectid = 0; } $absolute_discount = $soc->getAvailableDiscounts(); - + $nbrow = 10; - + print '
'; print ''; print ''; @@ -1362,18 +1368,18 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; print ''; print ''; - + print ''; - + // Reference print ''; - + // Reference client print ''; print ''; // We must not use ref_client of proposal for an order print ''; - + // Client print ''; print ''; @@ -1388,7 +1394,7 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; } print '' . "\n"; - + /* * Contact de la commande */ @@ -1396,7 +1402,7 @@ if ($action == 'create' && $user->rights->commande->creer) { print "'; - + // Ligne info remises tiers print ''; - + // Date de livraison print ""; - + // Conditions de reglement print ''; - + // Mode de reglement print ''; - + // Delivery delay print ''; - + // What trigger creation print ''; - + // Project if (! empty($conf->projet->enabled) && $socid > 0) { $formproject = new FormProjets($db); - + print ''; } - + // Other attributes $parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by @@ -1467,7 +1473,7 @@ if ($action == 'create' && $user->rights->commande->creer) { if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } - + // Template to use by default print ''; print '"; - + // Note publique print ''; print ''; print ''; - + // Note privee if (! $user->societe_id) { print ''; print ''; print ''; } - + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { // TODO for compatibility if ($origin == 'contrat') { @@ -1506,7 +1512,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $objectsrc->remise_percent = $remise_percent; $objectsrc->update_price(1); } - + print "\n"; print "\n"; print '' . "\n"; @@ -1514,7 +1520,7 @@ if ($action == 'create' && $user->rights->commande->creer) { print '' . "\n"; print ''; print ''; - + $newclassname = $classname; if ($newclassname == 'Propal') $newclassname = 'CommercialProposal'; @@ -1525,12 +1531,12 @@ if ($action == 'create' && $user->rights->commande->creer) { { print '"; } - + if ($mysoc->localtax2_assuj == "1") // Localtax2 IRPF { print '"; } - + print '"; } else { if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) { @@ -1538,9 +1544,9 @@ if ($action == 'create' && $user->rights->commande->creer) { * Services/produits predefinis */ $NBLINES = 8; - + print ''; } } - + print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; // print '
' . $langs->trans('Customer') . '
" . $langs->trans("DefaultContact") . ''; $form->select_contacts($soc->id, $setcontact, 'contactidp', 1, $srccontactslist); print '
' . $langs->trans('Discounts') . ''; if ($soc->remise_percent) @@ -1416,7 +1422,7 @@ if ($action == 'create' && $user->rights->commande->creer) { print '
' . $langs->trans('Date') . ''; $form->select_date('', 're', '', '', '', "crea_commande", 1, 1); print '
" . $langs->trans("DeliveryDate") . ''; if (empty($datedelivery)) { @@ -1427,31 +1433,31 @@ if ($action == 'create' && $user->rights->commande->creer) { } $form->select_date($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1); print "
' . $langs->trans('PaymentConditionsShort') . ''; $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); print '
' . $langs->trans('PaymentMode') . ''; $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id'); print '
' . $langs->trans('AvailabilityPeriod') . ''; $form->select_availability($availability_id, 'availability_id', '', 1); print '
' . $langs->trans('Source') . ''; $form->select_demand_reason($demand_reason_id, 'demand_reason_id', '', 1); print '
' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects($soc->id, $projectid); if ($numprojet == 0) { @@ -1459,7 +1465,7 @@ if ($action == 'create' && $user->rights->commande->creer) { } print '
' . $langs->trans('Model') . ''; @@ -1475,29 +1481,29 @@ if ($action == 'create' && $user->rights->commande->creer) { $liste = ModelePDFCommandes::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); print "
' . $langs->trans('NotePublic') . ''; - + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); // print ''; print '
' . $langs->trans('NotePrivate') . ''; - + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); // print ''; print '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . "
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
'; - + print ''; print ''; print ''; @@ -1557,28 +1563,28 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; print ''; } - + print '
' . $langs->trans('ProductsAndServices') . '' . $langs->trans('Qty') . '%
'; print '
'; - + // Button "Create Draft" print '
'; - + print '
'; - + // Show origin lines if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); print_titre($title); - + print ''; - + $objectsrc->printOriginLinesList(); - + print '
'; } } else { @@ -1588,30 +1594,30 @@ if ($action == 'create' && $user->rights->commande->creer) { /* */ /* *************************************************************************** */ $now = dol_now(); - + if ($object->id > 0) { dol_htmloutput_mesg($mesg, $mesgs); - + $product_static = new Product($db); - + $soc = new Societe($db); $soc->fetch($object->socid); - + $author = new User($db); $author->fetch($object->user_author_id); - + $head = commande_prepare_head($object); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); - + $formconfirm = ''; - + /* * Confirmation de la suppression de la commande */ if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } - + /* * Confirmation de la validation */ @@ -1623,7 +1629,7 @@ if ($action == 'create' && $user->rights->commande->creer) { } else { $numref = $object->ref; } - + $text = $langs->trans('ConfirmValidateOrder', $numref); if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; @@ -1644,10 +1650,10 @@ if ($action == 'create' && $user->rights->commande->creer) { // 'value' => 1), array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'), 'idwarehouse', '', 1))); } - + $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); } - + // Confirm back to draft status if ($action == 'modif') { $text = $langs->trans('ConfirmUnvalidateOrder', $object->ref); @@ -1664,17 +1670,17 @@ if ($action == 'create' && $user->rights->commande->creer) { // 'value' => 1), array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'), 'idwarehouse', '', 1))); } - + $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); } - + /* * Confirmation de la cloture */ if ($action == 'shipped') { $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_shipped', '', 0, 1); } - + /* * Confirmation de l'annulation */ @@ -1693,17 +1699,17 @@ if ($action == 'create' && $user->rights->commande->creer) { // 'value' => 1), array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'), 'idwarehouse', '', 1))); } - + $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); } - + /* * Confirmation de la suppression d'une ligne produit */ if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } - + // Clone confirmation if ($action == 'clone') { // Create an array for form @@ -1717,40 +1723,40 @@ if ($action == 'create' && $user->rights->commande->creer) { // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneOrder'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - + if (! $formconfirm) { $parameters = array('lineid' => $lineid); $formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified // by hook } - + // Print form confirm print $formconfirm; - + /* * Commande */ $nbrow = 9; if (! empty($conf->projet->enabled)) $nbrow ++; - + // Local taxes if ($mysoc->localtax1_assuj == "1") $nbrow ++; if ($mysoc->localtax2_assuj == "1") $nbrow ++; - + print ''; - + $linkback = '' . $langs->trans("BackToList") . ''; - + // Ref print ''; print ''; print ''; - + // Ref commande client print '
' . $langs->trans('Ref') . ''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); print '
'; print ''; print ''; - + // Third party print ''; print ''; print ''; - + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final // invoice @@ -1786,12 +1792,12 @@ if ($action == 'create' && $user->rights->commande->creer) { $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')"; $filtercreditnote = "fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'"; } - + // Relative and absolute discounts $addrelativediscount = '' . $langs->trans("EditRelativeDiscounts") . ''; $addabsolutediscount = '' . $langs->trans("EditGlobalDiscounts") . ''; $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; - + print ''; - + // Date print ''; print ''; - + // Delivery date planed print '
'; @@ -1772,12 +1778,12 @@ if ($action == 'create' && $user->rights->commande->creer) { } print '
' . $langs->trans('Company') . '' . $soc->getNomUrl(1) . '
' . $langs->trans('Discounts') . ''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); @@ -1817,13 +1823,13 @@ if ($action == 'create' && $user->rights->commande->creer) { if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.'; print '
'; print ''; - + if ($action != 'editdate' && $object->brouillon) print ''; print '
'; print $langs->trans('Date'); print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
'; @@ -1840,7 +1846,7 @@ if ($action == 'create' && $user->rights->commande->creer) { } print '
'; print ''; print ''; - + // Terms of payment print '
'; @@ -1862,7 +1868,7 @@ if ($action == 'create' && $user->rights->commande->creer) { } print '
'; print ''; - + print ''; - + // Mode of payment print '
'; @@ -1878,9 +1884,9 @@ if ($action == 'create' && $user->rights->commande->creer) { $form->form_conditions_reglement($_SERVER ['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none', 1); } print '
'; print ''; - + // Availability print '
'; @@ -1896,7 +1902,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $form->form_modes_reglement($_SERVER ['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); } print '
'; print ''; - + // Source print ' - +
'; @@ -1912,7 +1918,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $form->form_availability($_SERVER ['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1); } print '
'; print ''; - + // Project if (! empty($conf->projet->enabled)) { $langs->load('projects'); @@ -1952,7 +1958,7 @@ if ($action == 'create' && $user->rights->commande->creer) { } print ''; } - + if ($soc->outstanding_limit) { // Outstanding Bill print ''; print ''; } - + // Other attributes (TODO Move this into an include) $res = $object->fetch_optionals($object->id, $extralabels); $parameters = array('colspan' => ' colspan="3"'); @@ -1987,16 +1993,16 @@ if ($action == 'create' && $user->rights->commande->creer) { if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) { $value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); } - + if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) { print ''; print ''; print ''; print ''; print ''; - + print $extrafields->showInputField($key, $value); - + print ''; print ''; } else { @@ -2008,17 +2014,17 @@ if ($action == 'create' && $user->rights->commande->creer) { } } } - + $rowspan = 4; if ($mysoc->localtax1_assuj == "1") $rowspan ++; if ($mysoc->localtax2_assuj == "1") $rowspan ++; - + // Total HT print ''; print ''; - + // Margin Infos if (! empty($conf->margin->enabled)) { print ''; } else print ''; - + print ''; - + // Total TVA print ''; - + // Amount Local Taxes if ($mysoc->localtax1_assuj == "1") // Localtax1 RE { @@ -2043,90 +2049,90 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; print ''; } - + // Total TTC print ''; - + // Statut print ''; - + print '
'; @@ -1932,7 +1938,7 @@ if ($action == 'create' && $user->rights->commande->creer) { // print ''; // print ''.$langs->trans("DictionarySource").''; print '
'; @@ -1963,7 +1969,7 @@ if ($action == 'create' && $user->rights->commande->creer) { print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ''; @@ -2026,12 +2032,12 @@ if ($action == 'create' && $user->rights->commande->creer) { print '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '

'; print "\n"; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; } - + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; } - + /* * Lines */ $result = $object->getLinesArray(); - + print '
'; - + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } - + print ''; - + // Show object lines if (! empty($object->lines)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); - + $numlines = count($object->lines); - + /* * Form to add new line */ if ($object->statut == 0 && $user->rights->commande->creer) { if ($action != 'editline') { $var = true; - + if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services $object->formAddObjectLine(1, $mysoc, $soc); } else { // Add free products/services $object->formAddFreeProduct(1, $mysoc, $soc); - + // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var = ! $var; $object->formAddPredefinedProduct(1, $mysoc, $soc); } } - + $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook } } print '
'; - + print "
\n"; - + dol_fiche_end(); - + /* * Boutons actions */ if ($action != 'presend' && $action != 'editline') { print '
'; - + $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook @@ -2153,12 +2159,12 @@ if ($action == 'create' && $user->rights->commande->creer) { } else print ''; } - + // Ship $numshipping = 0; if (! empty($conf->expedition->enabled)) { $numshipping = $object->nb_expedition(); - + if ($object->statut > 0 && $object->statut < 3 && $object->getNbOfProductsLines() > 0) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if ($user->rights->expedition->creer) { @@ -2172,11 +2178,11 @@ if ($action == 'create' && $user->rights->commande->creer) { } } } - + // Create intervention if ($conf->ficheinter->enabled) { $langs->load("interventions"); - + if ($object->statut > 0 && $object->statut < 3 && $object->getNbOfServicesLines() > 0) { if ($user->rights->ficheinter->creer) { print ''; @@ -2185,21 +2191,21 @@ if ($action == 'create' && $user->rights->commande->creer) { } } } - + // Reopen a closed order if ($object->statut == 3 && $user->rights->commande->creer) { print ''; } - + // Create contract if ($conf->contrat->enabled && ($object->statut == 1 || $object->statut == 2)) { $langs->load("contracts"); - + if ($user->rights->contrat->creer) { print ''; } } - + // Create bill and Classify billed // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" if ($object->statut > 0 && ! $object->billed) { @@ -2210,22 +2216,22 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; } } - + // Set to shipped if (($object->statut == 1 || $object->statut == 2) && $user->rights->commande->cloturer) { print ''; } - + // Clone if ($user->rights->commande->creer) { print ''; } - + // Cancel order if ($object->statut == 1 && $user->rights->commande->annuler) { print ''; } - + // Delete order if ($user->rights->commande->supprimer) { if ($numshipping == 0) { @@ -2238,12 +2244,12 @@ if ($action == 'create' && $user->rights->commande->creer) { print '
'; } print '
'; - + if ($action != 'presend') { print '
'; // print '
'; // print ''; // ancre - + /* * Documents generes */ @@ -2255,24 +2261,24 @@ if ($action == 'create' && $user->rights->commande->creer) { $genallowed = $user->rights->commande->creer; $delallowed = $user->rights->commande->supprimer; $somethingshown = $formfile->show_documents('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - + /* * Linked object block */ $somethingshown = $object->showLinkedObjectBlock(); - + print '
'; // print '
'; - + // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'order', $socid); - + // print '
'; print '
'; } - + /* * Action presend * @@ -2282,7 +2288,7 @@ if ($action == 'create' && $user->rights->commande->creer) { include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/')); $file = $fileparams ['fullname']; - + // Build document if it not exists if (! $file || ! is_readable($file)) { // Define output language @@ -2296,7 +2302,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $result = commande_pdf_create($db, $object, GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db, $result); @@ -2305,10 +2311,10 @@ if ($action == 'create' && $user->rights->commande->creer) { $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/')); $file = $fileparams ['fullname']; } - + print '
'; print_titre($langs->trans('SendOrderByMail')); - + // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -2338,11 +2344,11 @@ if ($action == 'create' && $user->rights->commande->creer) { $formmail->substit ['__REFCLIENT__'] = $object->ref_client; $formmail->substit ['__PERSONALIZED__'] = ''; $formmail->substit ['__CONTACTCIVNAME__'] = ''; - + $custcontact = ''; $contactarr = array(); $contactarr = $object->liste_contact(- 1, 'external'); - + if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { if ($contact ['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { @@ -2351,27 +2357,27 @@ if ($action == 'create' && $user->rights->commande->creer) { $custcontact = $contactstatic->getFullName($langs, 1); } } - + if (! empty($custcontact)) { $formmail->substit ['__CONTACTCIVNAME__'] = $custcontact; } } - + // Tableau des parametres complementaires $formmail->param ['action'] = 'send'; $formmail->param ['models'] = 'order_send'; $formmail->param ['orderid'] = $object->id; $formmail->param ['returnurl'] = $_SERVER ["PHP_SELF"] . '?id=' . $object->id; - + // Init list of files if (GETPOST("mode") == 'init') { $formmail->clear_attached_files(); $formmail->add_attached_files($file, basename($file), dol_mimetype($file)); } - + // Show form print $formmail->get_form(); - + print '
'; } } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 74bf7c40ad8..70b173ab014 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -117,8 +117,8 @@ if ($action == 'add') if (! $error) { - // Type et taille non encore pris en compte => varchar(255) - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname'])) + // attrname must be alphabetical and lower case only + if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname'])) { // Construct array for parameter (value of select list) $default_value = GETPOST('default_value'); @@ -159,7 +159,7 @@ if ($action == 'add') { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode")); + $mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode")); setEventMessage($mesg,'errors'); $action = 'create'; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2dc8a454ae0..deeb7c122be 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2413,7 +2413,7 @@ class Form * * @param string $selected Id account pre-selected * @param string $htmlname Name of select zone - * @param int $statut Status of searched accounts (0=open, 1=closed) + * @param int $statut Status of searched accounts (0=open, 1=closed, 2=both) * @param string $filtre To filter list * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @param string $moreattrib To add more attribute on select @@ -2425,10 +2425,10 @@ class Form $langs->load("admin"); - $sql = "SELECT rowid, label, bank"; + $sql = "SELECT rowid, label, bank, clos as status"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE clos = '".$statut."'"; - $sql.= " AND entity IN (".getEntity('bank_account', 1).")"; + $sql.= " WHERE entity IN (".getEntity('bank_account', 1).")"; + if ($statut != 2) $sql.= " AND clos = '".$statut."'"; if ($filtre) $sql.=" AND ".$filtre; $sql.= " ORDER BY label"; @@ -2458,6 +2458,7 @@ class Form print ''; $i++; } diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index fb7fa20533b..e606a2db5a5 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -187,8 +187,8 @@ class modProjet extends DolibarrModules $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country', 's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', - 'p.rowid'=>"ProjectId",'p.ref'=>"ProjectRef",'p.datec'=>"DateCreation",'p.dateo'=>"DateDebutProjet",'p.datee'=>"DateFinProjet",'p.fk_statut'=>'ProjectStatus','p.description'=>"projectNote", - 'pt.rowid'=>'RefTask','pt.dateo'=>"TaskDateo",'pt.datee'=>"TaskDatee",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"DurationPlanned",'pt.progress'=>"Progress",'pt.description'=>"TaskDesc", + 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'Status','p.description'=>"Description", + 'pt.rowid'=>'RefTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription", 'ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"); $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_pays:libelle', @@ -197,10 +197,10 @@ class modProjet extends DolibarrModules 'pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Number",'pt.progress'=>"Number",'pt.description'=>"Text", 'ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:Name",'ptt.note'=>"Text"); - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company', - 's.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - 'f.rowid'=>"project",'f.ref'=>"project",'f.datec'=>"project",'f.duree'=>"project",'f.fk_statut'=>"project",'f.description'=>"project", - 'pt.rowid'=>'task','pt.dateo'=>"task",'pt.datee'=>"task",'pt.duration_effective'=>"task",'pt.planned_workload'=>"task",'pt.progress'=>"task",'pt.description'=>"task", + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company', + 's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', + 'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'p.description'=>"project", + 'pt.rowid'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask", 'ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"); diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 257f37c5411..e0be7ece744 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -209,7 +209,7 @@ class modUser extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs'; $this->export_permission[$r]=array(array("user","user","export")); - $this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.office_phone'=>'Telephone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Admin",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_societe'=>"IdCompany",'u.fk_member'=>"MemberId"); + $this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_societe'=>"IdCompany",'u.fk_member'=>"MemberId"); $this->export_TypeFields_array[$r]=array('u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.office_phone'=>'Text','u.office_fax'=>'Text','u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date','u.datepreviouslogin'=>'Date','u.fk_societe'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:nom"); $this->export_entities_array[$r]=array('u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.office_phone'=>'user','u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_societe'=>"company",'u.fk_member'=>"member"); diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 584a4941777..affee5274ca 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2009 Laurent Destailleur + * Copyright (C) 2006-2014 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,8 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php' /** - * \class mod_codeclient_leopard - * \brief Classe permettant la gestion leopard des codes tiers + * Class to manage numbering of thirdparties code */ class mod_codeclient_leopard extends ModeleThirdPartyCode { @@ -104,7 +103,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode global $conf; $result=0; - $code = strtoupper(trim($code)); + $code = trim($code); if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { @@ -115,9 +114,9 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode $result=-2; } - dol_syslog("mod_codeclient_leopard::verif type=".$type." result=".$result); + dol_syslog(get_class($this)."::verif type=".$type." result=".$result); return $result; } } -?> +?> \ No newline at end of file diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index d1f8fc6bb37..e4c4d75c85e 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -70,7 +70,7 @@
trans("Label"); ?>
trans("AttributeCode"); ?> (trans("AlphaNumOnlyCharsAndNoSpace"); ?>)
trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)
trans("Type"); ?> selectarray('type',$type2label,GETPOST('type')); ?> diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 39225d26d6e..42299a755b5 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -430,30 +430,25 @@ class Export * * @param string $TypeField Type of Field to filter * @return string html string of the input field ex : "" - * TODO replace by translation */ function genDocFilter($TypeField) { + global $langs; + $szMsg=''; $InfoFieldList = explode(":", $TypeField); // build the input field on depend of the type of file switch ($InfoFieldList[0]) { case 'Text': - $szMsg="% permet de remplacer un ou plusieurs caractères dans la chaine"; + $szMsg= $langs->trans('ExportStringFilter'); break; case 'Date': - $szMsg ="'AAAA' 'AAAAMM' 'AAAAMMJJ' : filtre sur une année/mois/jour
"; - $szMsg.="'AAAA+AAAA' 'AAAAMM+AAAAMM' 'AAAAMMJJ+AAAAMMJJ': filtre sur une plage d'année/mois/jour
"; - $szMsg.="'>AAAA' '>AAAAMM' '>AAAAMMJJ' filtre sur les année/mois/jour suivants
"; - $szMsg.="'‹AAAA' '‹AAAAMM' '‹AAAAMMJJ' filtre sur les année/mois/jour précédent
"; + $szMsg = $langs->trans('ExportDateFilter'); break; case 'Duree': break; case 'Numeric': - $szMsg ="'NNNNN' filtre sur une valeur
"; - $szMsg.="'NNNNN+NNNNN' filtre sur une plage de valeur
"; - $szMsg.="'‹NNNNN' filtre sur les valeurs inférieurs
"; - $szMsg.="'>NNNNN' filtre sur les valeurs supérieurs
"; + $szMsg = $langs->trans('ExportNumericFilter'); break; case 'Boolean': break; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 020d6dc9286..d9d3aa91544 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -91,7 +91,10 @@ $entitytolang = array( 'other' => 'Other', 'trip' => 'TripsAndExpenses', 'shipment' => 'Shipments', - 'shipment_line'=> 'ShipmentLine' + 'shipment_line'=> 'ShipmentLine', + 'project' => 'Projects', + 'projecttask' => 'Tasks', + 'task_time' => 'TaskTimeSpent' ); $array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 15d5b038f7c..ce3966b68fd 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -993,6 +993,7 @@ ExtraFieldsProject=Complementary attributes (projects) ExtraFieldsProjectTask=Complementary attributes (tasks) ExtraFieldHasWrongValue=Attribut %s has a wrong value. AlphaNumOnlyCharsAndNoSpace=only alphanumericals characters without space +AlphaNumOnlyLowerCharsAndNoSpace=only alphanumericals and lower case characters without space SendingMailSetup=Setup of sendings by email SendmailOptionNotComplete=Warning, on some Linux systems, to send email from your email, sendmail execution setup must contains option -ba (parameter mail.force_extra_parameters into your php.ini file). If some recipients never receive emails, try to edit this PHP parameter with mail.force_extra_parameters = -ba). PathToDocuments=Path to documents diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index fa0b87cc506..b3908e70750 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -66,6 +66,7 @@ ErrorNoValueForCheckBoxType=Please fill value for checkbox list ErrorNoValueForRadioType=Please fill value for radio list ErrorBadFormatValueList=The list value cannot have more than one come : %s, but need at least one: llave,valores ErrorFieldCanNotContainSpecialCharacters=Field %s must not contains special characters. +ErrorFieldCanNotContainSpecialNorUpperCharacters=Field %s must not contains special characters, nor upper case characters. ErrorNoAccountancyModuleLoaded=No accountancy module activated ErrorExportDuplicateProfil=This profile name already exists for this export set. ErrorLDAPSetupNotComplete=Dolibarr-LDAP matching is not complete. @@ -150,4 +151,4 @@ WarningUntilDirRemoved=All security warnings (visible by admin users only) will WarningCloseAlways=Warning, closing is done even if amount differs between source and target elements. Enable this feature with caution. WarningUsingThisBoxSlowDown=Warning, using this box slow down seriously all pages showing the box. WarningClickToDialUserSetupNotComplete=Setup of ClickToDial information for your user are not complete (see tab ClickToDial onto your user card). -WarningNotRelevant=Irrelevant operation for this dataset \ No newline at end of file +WarningNotRelevant=Irrelevant operation for this dataset diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 974f0effffe..4d3eae83350 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -123,6 +123,10 @@ BankCode=Bank code DeskCode=Desk code BankAccountNumber=Account number BankAccountNumberKey=Key +SpecialCode=Special code +ExportStringFilter=%% allows replacing one or more characters in the text +ExportDateFilter='AAAA' 'AAAAMM' 'AAAAMMJJ': filters by one year/month/day
'AAAA+AAAA' 'AAAAMM+AAAAMM' 'AAAAMMJJ+AAAAMMJJ': filters over a range of years/months/days
'>AAAA' '>AAAAMM' '>AAAAMMJJ': filters on the following years/months/days
'>AAAA' '>AAAAMM' '>AAAAMMJJ': filters on the previous years/months/days +ExportNumericFilter='NNNNN' filters by one value
'NNNNN+NNNNN' filters over a range of values
'>NNNNN' filters by lower values
'>NNNNN' filters by higher values ## filters SelectFilterFields=If you want to filter on some values, just input values here. FilterableFields=Champs Filtrables diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index ba0b6b6dcd2..c6355cdec95 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -1,4 +1,6 @@ # Dolibarr language file - Source file is en_US - projects +RefProject=Ref. project +ProjectId=Project Id Project=Project Projects=Projects SharedProject=Everybody @@ -30,11 +32,18 @@ TimeSpent=Time spent TimesSpent=Time spent RefTask=Ref. task LabelTask=Label task +TaskTimeSpent=Time spent on tasks +TaskTimeUser=Task time user +TaskTimeNote=Task time note +TaskTimeDate=Task time date NewTimeSpent=New time spent MyTimeSpent=My time spent MyTasks=My tasks Tasks=Tasks Task=Task +TaskDateStart=Task start date +TaskDateEnd=Task end date +TaskDescription=Task description NewTask=New task AddTask=Add task AddDuration=Add duration diff --git a/htdocs/langs/es_ES/exports.lang b/htdocs/langs/es_ES/exports.lang index 8724ae4695e..009eb4f5293 100644 --- a/htdocs/langs/es_ES/exports.lang +++ b/htdocs/langs/es_ES/exports.lang @@ -123,6 +123,10 @@ BankCode=Código banco DeskCode=Código oficina BankAccountNumber=Número cuenta BankAccountNumberKey=Dígito Control +SpecialCode=Código especial +ExportStringFilter=%% permite reemplazar uno o más caracteres en el texto +ExportDateFilter='AAAA' 'AAAAMM' 'AAAAMMJJ': filtra por un año/mes/día
'AAAA+AAAA' 'AAAAMM+AAAAMM' 'AAAAMMJJ+AAAAMMJJ': filtra entre un rango de años/meses/días
'>AAAA' '>AAAAMM' '>AAAAMMJJ': filtra por los siguientes años/meses/días
'‹AAAA' '‹AAAAMM' '‹AAAAMMJJ': filtra por los anteriores años/meses/días +ExportNumericFilter='NNNNN' filtra por un valor
'NNNNN+NNNNN' filtra entre un rango de valores
'‹NNNNN' filtra por valores inferiores
'>NNNNN' filtra por valores superiores ## filters SelectFilterFields=Si quiere aplicar un filtro sobre algunos valores, introdúzcalos aquí. FilterableFields=Campos filtrables diff --git a/htdocs/langs/es_ES/projects.lang b/htdocs/langs/es_ES/projects.lang index 1df7fd8d92a..04e5723e9f2 100644 --- a/htdocs/langs/es_ES/projects.lang +++ b/htdocs/langs/es_ES/projects.lang @@ -1,4 +1,6 @@ # Dolibarr language file - Source file is en_US - projects +RefProject=Ref. proyecto +ProjectId=Id proyecto Project=Proyecto Projects=Proyectos SharedProject=Proyecto compartido @@ -30,11 +32,18 @@ TimeSpent=Tiempo dedicado TimesSpent=Tiempos dedicados RefTask=Ref. tarea LabelTask=Etiqueta tarea +TaskTimeSpent=Tiempo dedicado a tareas +TaskTimeUser=Usuario de tiempo dedicado +TaskTimeNote=Nota de tiempo dedicado +TaskTimeDate=Fecha de tiempo dedicado NewTimeSpent=Nuevo tiempo dedicado MyTimeSpent=Mi tiempo dedicado MyTasks=Mis tareas Tasks=Tareas Task=Tarea +TaskDateStart=Fecha inicio tarea +TaskDateEnd=Fecha fin tarea +TaskDescription=Descripción de tarea NewTask=Nueva tarea AddTask=Añadir tarea AddDuration=Indicar duración diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 8f7e3504f08..215ea7900ef 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -985,6 +985,7 @@ ExtraFieldsProject=Attributs supplémentaires (projets) ExtraFieldsProjectTask=Attributs supplémentaires (tâches) ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte. AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace +AlphaNumOnlyLowerCharsAndNoSpace=uniquement caractères minuscules alphanumériques sans espace SendingMailSetup=Configuration de l'envoi par email SendmailOptionNotComplete=Attention, sur certains systèmes Linux, avec cette méthode d'envoi, pour pouvoir envoyer des emails en votre nom, la configuration d'exécution de sendmail doit contenir l'option -ba (paramètre mail.force_extra_parameters dans le fichier php.ini). Si certains de vos destinataires ne reçoivent pas de message, essayer de modifier ce paramètre PHP avec mail.force_extra_parameters = -ba. PathToDocuments=Chemin d'accès aux documents diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 52d8605374f..cde17552709 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -63,6 +63,7 @@ ErrorNoValueForCheckBoxType=Les valeurs de la liste de case a cochées doivent ErrorNoValueForRadioType=Les valeurs de la liste d'options doivent être renseignées ErrorBadFormatValueList=Les valeurs de la liste ne peuvent pas contenir plus d'une virgule : %s, mais doivent en avoir au moins une: clef,valeur ErrorFieldCanNotContainSpecialCharacters=Le champ %s ne peut contenir de caractères spéciaux. +ErrorFieldCanNotContainSpecialNorUpperCharacters=Le champ %s ne peut contenir de caractères spéciaux, ni de caractères en majuscules. ErrorNoAccountancyModuleLoaded=Aucun module de comptabilité activé ErrorExportDuplicateProfil=Ce nom de profil existe déjà pour ce lot d'export. ErrorLDAPSetupNotComplete=Le matching Dolibarr-LDAP est incomplet. diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 1d4d5f25314..e79856b19bf 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -123,6 +123,9 @@ BankCode=Code banque DeskCode=Code guichet BankAccountNumber=Numéro de compte BankAccountNumberKey=Clé RIB +ExportStringFilter=%% permet de remplacer un ou plusieurs caractères dans la chaine +ExportDateFilter='AAAA' 'AAAAMM' 'AAAAMMJJ': filtre sur une année/mois/jour
'AAAA+AAAA' 'AAAAMM+AAAAMM' 'AAAAMMJJ+AAAAMMJJ': filtre sur une plage d'année/mois/jour
'>AAAA' '>AAAAMM' '>AAAAMMJJ': filtre sur les année/mois/jour suivants
'>AAAA' '>AAAAMM' '>AAAAMMJJ' filtre sur les année/mois/jour précédent +ExportNumericFilter='NNNNN' filtre sur une valeur
'NNNNN+NNNNN' filtre sur une plage de valeur
'>NNNNN' filtre sur les valeurs inférieurs
'>NNNNN' filtre sur les valeurs supérieurs ## filters SelectFilterFields=Si vous voulez filtrer sur certaines valeurs, saisissez ces valeurs. FilterableFields=Champs filtrables diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 225a2dab5c8..a3847060fdb 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -315,6 +315,7 @@ class Societe extends CommonObject $contact->statut = 1; $contact->priv = 0; $contact->country_id = $this->country_id; + $contact->state_id = $this->state_id; $contact->address = $this->address; $contact->email = $this->email; $contact->zip = $this->zip; diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php index 3743a95f342..16068b827d9 100644 --- a/htdocs/theme/cameleo/style.css.php +++ b/htdocs/theme/cameleo/style.css.php @@ -1349,7 +1349,7 @@ div.divButAction { margin-bottom: 1.4em; } .butActionRefused { background: #FFe7ec; - color: #666; + color: #aaa !important; } global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?> @@ -1606,6 +1606,7 @@ tr.pair td.nohover { -webkit-box-shadow: 4px 4px 4px #DDD; box-shadow: 4px 4px 4px #DDD; margin-bottom: 8px !important;*/ + background: #FFFFFF; border: 1px solid #AAA; text-align: center; border-radius: 5px; diff --git a/htdocs/theme/eldy/img/object_task_time.png b/htdocs/theme/eldy/img/object_task_time.png new file mode 100644 index 00000000000..8cda1f3f220 Binary files /dev/null and b/htdocs/theme/eldy/img/object_task_time.png differ