--- /tmp/dsg/dolibarr/htdocs/commande/github_card.php
+++ /tmp/dsg/dolibarr/htdocs/commande/client_card.php
@@ -67,7 +67,7 @@
$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int'));
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
-$action = GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$lineid = GETPOST('lineid', 'int');
@@ -120,8 +120,6 @@
$error = 0;
-$date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
-
/*
* Actions
@@ -156,7 +154,9 @@
if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers'))
{
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
- } else {
+ }
+ else
+ {
if ($object->id > 0)
{
// Because createFromClone modifies the object, we must clone it so that we can restore it later
@@ -167,7 +167,9 @@
{
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
exit;
- } else {
+ }
+ else
+ {
setEventMessages($object->error, $object->errors, 'errors');
$object = $orig;
$action = '';
@@ -185,7 +187,9 @@
if ($result > 0)
{
setEventMessages($langs->trans('OrderReopened', $object->ref), null);
- } else {
+ }
+ else
+ {
setEventMessages($object->error, $object->errors, 'errors');
}
}
@@ -199,7 +203,9 @@
{
header('Location: list.php?restore_lastsearch_values=1');
exit;
- } else {
+ }
+ else
+ {
setEventMessages($object->error, $object->errors, 'errors');
}
}
@@ -223,12 +229,14 @@
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$ret = $object->fetch($object->id); // Reload to get new records
- $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
- } else {
+ }
+ else
+ {
setEventMessages($object->error, $object->errors, 'errors');
}
}
@@ -243,8 +251,8 @@
elseif ($action == 'add' && $usercancreate)
{
$datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
- $date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
- $selectedLines = GETPOST('toselect', 'array');
+ $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
+ $selectedLines = GETPOST('toselect', 'array');
if ($datecommande == '') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
@@ -265,23 +273,22 @@
$db->begin();
$object->date_commande = $datecommande;
- $object->note_private = GETPOST('note_private', 'restricthtml');
- $object->note_public = GETPOST('note_public', 'restricthtml');
+ $object->note_private = GETPOST('note_private', 'none');
+ $object->note_public = GETPOST('note_public', 'none');
$object->source = GETPOST('source_id');
$object->fk_project = GETPOST('projectid', 'int');
$object->ref_client = GETPOST('ref_client', 'alpha');
- $object->model_pdf = GETPOST('model');
+ $object->modelpdf = GETPOST('model');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id');
- $object->date_livraison = $date_delivery; // deprecated
- $object->delivery_date = $date_delivery;
+ $object->date_livraison = $datelivraison;
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->fk_delivery_address = GETPOST('fk_address');
- $object->contact_id = GETPOST('contactid');
+ $object->contactid = GETPOST('contactid');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
@@ -352,7 +359,7 @@
for ($i = 0; $i < $num; $i++)
{
- if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines
+ if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines
$label = (!empty($lines[$i]->label) ? $lines[$i]->label : '');
$desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : '');
@@ -420,7 +427,7 @@
$originidforcontact=$srcobject->origin_id;
}
$sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
- $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$db->escape($originforcontact)."'";
+ $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
$resqlcontact = $db->query($sqlcontact);
if ($resqlcontact)
@@ -453,14 +460,26 @@
if (!$error)
{
$object_id = $object->create($user);
+
+ // If some invoice's lines already known
+ $NBLINES = 8;
+ for ($i = 1; $i <= $NBLINES; $i++) {
+ if ($_POST['idprod'.$i]) {
+ $xid = 'idprod'.$i;
+ $xqty = 'qty'.$i;
+ $xremise = 'remise_percent'.$i;
+ $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]);
+ }
+ }
}
}
// Insert default contacts if defined
if ($object_id > 0)
{
- if (GETPOST('contactid', 'int')) {
- $result = $object->add_contact(GETPOST('contactid', 'int'), 'CUSTOMER', 'external');
+ if (GETPOST('contactid'))
+ {
+ $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external');
if ($result < 0) {
setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors');
$error++;
@@ -483,14 +502,17 @@
setEventMessages($object->error, $object->errors, 'errors');
}
}
- } elseif ($action == 'classifybilled' && $usercancreate)
+ }
+
+ elseif ($action == 'classifybilled' && $usercancreate)
{
$ret = $object->classifyBilled($user);
if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'classifyunbilled' && $usercancreate)
+ }
+ elseif ($action == 'classifyunbilled' && $usercancreate)
{
$ret = $object->classifyUnBilled();
if ($ret < 0) {
@@ -505,13 +527,17 @@
{
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'setremise' && $usercancreate) {
+ }
+
+ elseif ($action == 'setremise' && $usercancreate) {
$result = $object->set_remise($user, GETPOST('remise'));
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'setabsolutediscount' && $usercancreate) {
+ }
+
+ elseif ($action == 'setabsolutediscount' && $usercancreate) {
if (GETPOST('remise_id')) {
if ($object->id > 0) {
$object->insert_discount(GETPOST('remise_id'));
@@ -519,7 +545,9 @@
dol_print_error($db, $object->error);
}
}
- } elseif ($action == 'setdate' && $usercancreate) {
+ }
+
+ elseif ($action == 'setdate' && $usercancreate) {
// 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'));
@@ -527,16 +555,19 @@
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'setdate_livraison' && $usercancreate) {
+ }
+
+ elseif ($action == 'setdate_livraison' && $usercancreate) {
// print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
- $date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
-
- $object->fetch($id);
- $result = $object->setDeliveryDate($user, $date_delivery);
+ $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) {
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'setmode' && $usercancreate) {
+ }
+
+ elseif ($action == 'setmode' && $usercancreate) {
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
@@ -549,16 +580,22 @@
// Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
- $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
- } elseif ($action == 'setavailability' && $usercancreate) {
+ $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
+ }
+
+ elseif ($action == 'setavailability' && $usercancreate) {
$result = $object->availability(GETPOST('availability_id'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
- } elseif ($action == 'setdemandreason' && $usercancreate) {
+ }
+
+ elseif ($action == 'setdemandreason' && $usercancreate) {
$result = $object->demand_reason(GETPOST('demand_reason_id'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
- } elseif ($action == 'setconditions' && $usercancreate) {
+ }
+
+ elseif ($action == 'setconditions' && $usercancreate) {
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
if ($result < 0) {
dol_print_error($db, $object->error);
@@ -575,7 +612,7 @@
}
$ret = $object->fetch($object->id); // Reload to get new records
- $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
@@ -611,44 +648,41 @@
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'setremisepercent' && $usercancreate) {
+ }
+
+ elseif ($action == 'setremisepercent' && $usercancreate) {
$result = $object->set_remise($user, GETPOST('remise_percent'));
- } elseif ($action == 'setremiseabsolue' && $usercancreate) {
+ }
+
+ elseif ($action == 'setremiseabsolue' && $usercancreate) {
$result = $object->set_remise_absolue($user, GETPOST('remise_absolue'));
- } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '') {
- // Define vat_rate
- $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
- $vat_rate = str_replace('*', '', $vat_rate);
- $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
- $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
- foreach ($object->lines as $line) {
- $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
- }
- } elseif ($action == 'addline' && $usercancreate) // Add a new line
+ }
+
+ // Add a new line
+ elseif ($action == 'addline' && $usercancreate)
{
$langs->load('errors');
$error = 0;
// Set if we used free entry or predefined product
$predef = '';
- $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
- $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
- $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
+ $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
+ $price_ht = GETPOST('price_ht');
+ $price_ht_devise = GETPOST('multicurrency_price_ht');
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
- } else {
+ }
+ else
+ {
$idprod = GETPOST('idprod', 'int');
$tva_tx = '';
}
- $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
- $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha')) : 0);
- if (empty($remise_percent)) {
- $remise_percent = 0;
- }
+ $qty = GETPOST('qty'.$predef);
+ $remise_percent = (GETPOST('remise_percent'.$predef) != '' ? GETPOST('remise_percent'.$predef) : 0);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@@ -690,7 +724,9 @@
if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
$idprod = $res->fk_product_child;
- } else {
+ }
+ else
+ {
setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors');
$error++;
}
@@ -732,8 +768,8 @@
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
{
- if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
- if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
+ if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
+ if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
}
}
// If price per customer
@@ -752,14 +788,15 @@
{
$pu_ht = price($prodcustprice->lines[0]->price);
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
- $price_min = price($prodcustprice->lines[0]->price_min);
$price_base_type = $prodcustprice->lines[0]->price_base_type;
$tva_tx = $prodcustprice->lines[0]->tva_tx;
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
if (empty($tva_tx)) $tva_npr = 0;
}
- } else {
+ }
+ else
+ {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
}
@@ -779,7 +816,9 @@
if ($priceforthequantityarray['price_base_type'] == 'HT')
{
$pu_ht = $priceforthequantityarray['unitprice'];
- } else {
+ }
+ else
+ {
$pu_ttc = $priceforthequantityarray['unitprice'];
}
// Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST.
@@ -802,7 +841,9 @@
if ($priceforthequantityarray['price_base_type'] == 'HT')
{
$pu_ht = $priceforthequantityarray['unitprice'];
- } else {
+ }
+ else
+ {
$pu_ttc = $priceforthequantityarray['unitprice'];
}
// Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST.
@@ -815,7 +856,7 @@
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ?
- if (!empty($price_ht) || $price_ht === '0') {
+ if (!empty($price_ht)) {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
}
@@ -923,7 +964,6 @@
if ($result > 0) {
$ret = $object->fetch($object->id); // Reload to get new records
- $object->fetch_thirdparty();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
// Define output language
@@ -936,7 +976,7 @@
$outputlangs->setDefaultLang($newlang);
}
- $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
unset($_POST['prod_entry_mode']);
@@ -988,16 +1028,15 @@
$date_end = '';
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
- $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
- $pu_ht = price2num(GETPOST('price_ht'), '', 2);
+ $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'none'));
+ $pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0);
- $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
+ $pu_ht_devise = GETPOST('multicurrency_subprice');
// Define info_bits
$info_bits = 0;
- if (preg_match('/\*/', $vat_rate)) {
+ if (preg_match('/\*/', $vat_rate))
$info_bits |= 0x01;
- }
// Define vat_rate
$vat_rate = str_replace('*', '', $vat_rate);
@@ -1081,7 +1120,7 @@
}
$ret = $object->fetch($object->id); // Reload to get new records
- $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
unset($_POST['qty']);
@@ -1114,10 +1153,12 @@
setEventMessages($object->error, $object->errors, 'errors');
}
}
- } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans("Cancel")) {
+ } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) {
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition
exit();
- } elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate)
+ }
+
+ elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate)
{
$idwarehouse = GETPOST('idwarehouse', 'int');
@@ -1125,7 +1166,9 @@
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
$qualified_for_stock_change = $object->hasProductsOrServices(2);
- } else {
+ }
+ else
+ {
$qualified_for_stock_change = $object->hasProductsOrServices(1);
}
@@ -1155,12 +1198,14 @@
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- $model = $object->model_pdf;
+ $model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
- } else {
+ }
+ else
+ {
setEventMessages($object->error, $object->errors, 'errors');
}
}
@@ -1174,7 +1219,9 @@
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
$qualified_for_stock_change = $object->hasProductsOrServices(2);
- } else {
+ }
+ else
+ {
$qualified_for_stock_change = $object->hasProductsOrServices(1);
}
@@ -1204,19 +1251,23 @@
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- $model = $object->model_pdf;
+ $model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
- } elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) {
+ }
+
+ elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) {
$result = $object->cloture($user);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate)
+ }
+
+ elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate)
{
$idwarehouse = GETPOST('idwarehouse', 'int');
@@ -1224,7 +1275,9 @@
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
$qualified_for_stock_change = $object->hasProductsOrServices(2);
- } else {
+ }
+ else
+ {
$qualified_for_stock_change = $object->hasProductsOrServices(1);
}
@@ -1253,7 +1306,7 @@
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
- $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
+ $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (!$error)
@@ -1270,84 +1323,95 @@
if ($error) $action = 'edit_extras';
}
+ if ($action == 'set_thirdparty' && $usercancreate)
+ {
+ $object->fetch($id);
+ $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY');
+
+ header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
+ exit();
+ }
+
// add lines from objectlinked
if ($action == 'import_lines_from_object'
- && $usercancreate
- && $object->statut == Commande::STATUS_DRAFT
+ && $usercancreate
+ && $object->statut == Commande::STATUS_DRAFT
)
{
- $fromElement = GETPOST('fromelement');
- $fromElementid = GETPOST('fromelementid');
- $importLines = GETPOST('line_checkbox');
-
- if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid))
- {
- if ($fromElement == 'commande')
- {
- dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php');
- $lineClassName = 'OrderLine';
- } elseif ($fromElement == 'propal')
- {
- dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php');
- $lineClassName = 'PropaleLigne';
- }
- $nextRang = count($object->lines) + 1;
- $importCount = 0;
- $error = 0;
- foreach ($importLines as $lineId)
- {
- $lineId = intval($lineId);
- $originLine = new $lineClassName($db);
- if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0)
- {
- $originLine->fetch_optionals();
- $desc = $originLine->desc;
- $pu_ht = $originLine->subprice;
- $qty = $originLine->qty;
- $txtva = $originLine->tva_tx;
- $txlocaltax1 = $originLine->localtax1_tx;
- $txlocaltax2 = $originLine->localtax2_tx;
- $fk_product = $originLine->fk_product;
- $remise_percent = $originLine->remise_percent;
- $date_start = $originLine->date_start;
- $date_end = $originLine->date_end;
- $ventil = 0;
- $info_bits = $originLine->info_bits;
- $fk_remise_except = $originLine->fk_remise_except;
- $price_base_type = 'HT';
- $pu_ttc = 0;
- $type = $originLine->product_type;
- $rang = $nextRang++;
- $special_code = $originLine->special_code;
- $origin = $originLine->element;
- $origin_id = $originLine->id;
- $fk_parent_line = 0;
- $fk_fournprice = $originLine->fk_fournprice;
- $pa_ht = $originLine->pa_ht;
- $label = $originLine->label;
- $array_options = $originLine->array_options;
- $situation_percent = 100;
- $fk_prev_id = '';
- $fk_unit = $originLine->fk_unit;
- $pu_ht_devise = $originLine->multicurrency_subprice;
-
- $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise);
-
- if ($res > 0) {
- $importCount++;
- } else {
- $error++;
- }
- } else {
- $error++;
- }
- }
-
- if ($error)
- {
- setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors');
- }
- }
+ $fromElement = GETPOST('fromelement');
+ $fromElementid = GETPOST('fromelementid');
+ $importLines = GETPOST('line_checkbox');
+
+ if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid))
+ {
+ if ($fromElement == 'commande')
+ {
+ dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php');
+ $lineClassName = 'OrderLine';
+ }
+ elseif ($fromElement == 'propal')
+ {
+ dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php');
+ $lineClassName = 'PropaleLigne';
+ }
+ $nextRang = count($object->lines) + 1;
+ $importCount = 0;
+ $error = 0;
+ foreach ($importLines as $lineId)
+ {
+ $lineId = intval($lineId);
+ $originLine = new $lineClassName($db);
+ if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0)
+ {
+ $originLine->fetch_optionals();
+ $desc = $originLine->desc;
+ $pu_ht = $originLine->subprice;
+ $qty = $originLine->qty;
+ $txtva = $originLine->tva_tx;
+ $txlocaltax1 = $originLine->localtax1_tx;
+ $txlocaltax2 = $originLine->localtax2_tx;
+ $fk_product = $originLine->fk_product;
+ $remise_percent = $originLine->remise_percent;
+ $date_start = $originLine->date_start;
+ $date_end = $originLine->date_end;
+ $ventil = 0;
+ $info_bits = $originLine->info_bits;
+ $fk_remise_except = $originLine->fk_remise_except;
+ $price_base_type = 'HT';
+ $pu_ttc = 0;
+ $type = $originLine->product_type;
+ $rang = $nextRang++;
+ $special_code = $originLine->special_code;
+ $origin = $originLine->element;
+ $origin_id = $originLine->id;
+ $fk_parent_line = 0;
+ $fk_fournprice = $originLine->fk_fournprice;
+ $pa_ht = $originLine->pa_ht;
+ $label = $originLine->label;
+ $array_options = $originLine->array_options;
+ $situation_percent = 100;
+ $fk_prev_id = '';
+ $fk_unit = $originLine->fk_unit;
+ $pu_ht_devise = $originLine->multicurrency_subprice;
+
+ $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise);
+
+ if ($res > 0) {
+ $importCount++;
+ } else {
+ $error++;
+ }
+ }
+ else {
+ $error++;
+ }
+ }
+
+ if ($error)
+ {
+ setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors');
+ }
+ }
}
// Actions when printing a doc from card
@@ -1372,8 +1436,7 @@
{
if ($object->id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
- $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
- $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
+ $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source'));
}
if ($result >= 0) {
@@ -1469,10 +1532,12 @@
// For compatibility
if ($element == 'order' || $element == 'commande') {
$element = $subelement = 'commande';
- } elseif ($element == 'propal') {
+ }
+ elseif ($element == 'propal') {
$element = 'comm/propal';
$subelement = 'propal';
- } elseif ($element == 'contract') {
+ }
+ elseif ($element == 'contract') {
$element = $subelement = 'contrat';
}
@@ -1504,8 +1569,7 @@
$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
$dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : '';
- $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : '');
- if (empty($date_delivery)) $date_delivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : '');
+ $datedelivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : '');
if (!empty($conf->multicurrency->enabled))
{
@@ -1519,7 +1583,9 @@
// Object source contacts list
$srccontactslist = $objectsrc->liste_contact(-1, 'external', 1);
}
- } else {
+ }
+ else
+ {
$cond_reglement_id = $soc->cond_reglement_id;
$mode_reglement_id = $soc->mode_reglement_id;
$fk_account = $soc->fk_account;
@@ -1546,7 +1612,7 @@
print ' ';
if (!empty($currency_tx)) print ' ';
- print dol_get_fiche_head('');
+ dol_fiche_head('');
print '
';
@@ -1557,7 +1623,8 @@
print ''.$langs->trans('RefCustomer').' ';
if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid))
print ' ';
- else print ' ';
+ else
+ print ' ';
print ' ';
// Thirdparty
@@ -1570,14 +1637,13 @@
print '';
} else {
print '';
- print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx');
+ print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
// reload page to retrieve customer informations
- if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
+ if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
{
print '';
- }
-
print '';
print '
'."\n";
@@ -651,37 +635,37 @@
if (!empty($arrayfields['c.ref']['checked']))
{
print '';
- print ' ';
+ print ' ';
print ' ';
}
// Ref customer
if (!empty($arrayfields['c.ref_client']['checked']))
{
print '';
- print ' ';
+ print ' ';
print ' ';
}
// Project ref
if (!empty($arrayfields['p.ref']['checked']))
{
- print ' ';
+ print ' ';
}
// Project title
if (!empty($arrayfields['p.title']['checked']))
{
- print ' ';
+ print ' ';
}
// Thirpdarty
if (!empty($arrayfields['s.nom']['checked']))
{
print '';
- print ' ';
+ print ' ';
print ' ';
}
// Town
- if (!empty($arrayfields['s.town']['checked'])) print ' ';
+ if (!empty($arrayfields['s.town']['checked'])) print ' ';
// Zip
- if (!empty($arrayfields['s.zip']['checked'])) print ' ';
+ if (!empty($arrayfields['s.zip']['checked'])) print ' ';
// State
if (!empty($arrayfields['state.nom']['checked']))
{
@@ -708,10 +692,12 @@
{
print '';
print '';
- print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print $langs->trans('From').' ';
+ print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start', 0, 0, 1);
print '
';
print '';
- print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ print $langs->trans('to').' ';
+ print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end', 0, 0, 1);
print '
';
print ' ';
}
@@ -719,10 +705,12 @@
{
print '';
print '';
- print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print $langs->trans('From').' ';
+ print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start', 0, 0, 1);
print '
';
print '';
- print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ print $langs->trans('to').' ';
+ print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end', 0, 0, 1);
print '
';
print ' ';
}
@@ -730,14 +718,14 @@
{
// Amount
print '';
- print ' ';
+ print ' ';
print ' ';
}
if (!empty($arrayfields['c.total_vat']['checked']))
{
// Amount
print '';
- print ' ';
+ print ' ';
print ' ';
}
if (!empty($arrayfields['c.total_ttc']['checked']))
@@ -770,7 +758,7 @@
}
if (!empty($arrayfields['c.multicurrency_total_vat']['checked']))
{
- // Amount VAT
+ // Amount
print '';
print ' ';
print ' ';
@@ -810,51 +798,13 @@
// Date cloture
if (!empty($arrayfields['c.date_cloture']['checked']))
{
- print '';
- print '';
- print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
- print '
';
- print '';
- print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
- print '
';
- print ' ';
- }
- // Note public
- if (!empty($arrayfields['c.note_public']['checked']))
- {
print '';
- print ' ';
- }
- // Note private
- if (!empty($arrayfields['c.note_private']['checked']))
- {
- print '';
- print ' ';
- }
- // Shippable
- if (!empty($arrayfields['shippable']['checked']))
- {
- print '';
- //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1);
- if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) {
- print ' ';
- print $langs->trans('ShowShippableStatus');
- } else {
- $show_shippable_command = 1;
- }
- print ' ';
- }
- // Status billed
- if (!empty($arrayfields['c.facture']['checked']))
- {
- print '';
- print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
print ' ';
}
// Status
if (!empty($arrayfields['c.fk_statut']['checked']))
{
- print '';
+ print ' ';
$liststatus = array(
Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"),
Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"),
@@ -863,7 +813,14 @@
-3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort")
);
- print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1);
+ print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
+ print ' ';
+ }
+ // Status billed
+ if (!empty($arrayfields['c.facture']['checked']))
+ {
+ print '';
+ print $form->selectyesno('billed', $billed, 1, 0, 1);
print ' ';
}
// Action column
@@ -878,8 +835,8 @@
print '';
if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder);
- if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
- if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder);
+ if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
+ if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
@@ -907,18 +864,14 @@
if (!empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (!empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
- if (!empty($arrayfields['c.note_public']['checked'])) print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($arrayfields['c.note_private']['checked'])) print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($arrayfields['shippable']['checked'])) print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
+ if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
- if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
print ' '."\n";
$total = 0;
$subtotal = 0;
$productstat_cache = array();
- $productstat_cachevirtual = array();
$getNomUrl_cache = array();
$generic_commande = new Commande($db);
@@ -936,13 +889,13 @@
$text_warning = '';
$nbprod = 0;
- $companystatic->id = $obj->socid;
+ $companystatic->id = $obj->socid;
$companystatic->code_client = $obj->code_client;
$companystatic->name = $obj->name;
$companystatic->client = $obj->client;
$companystatic->email = $obj->email;
if (!isset($getNomUrl_cache[$obj->socid])) {
- $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
+ $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
}
$generic_commande->id = $obj->rowid;
@@ -950,8 +903,7 @@
$generic_commande->statut = $obj->fk_statut;
$generic_commande->billed = $obj->billed;
$generic_commande->date = $db->jdate($obj->date_commande);
- $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated
- $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
+ $generic_commande->date_livraison = $db->jdate($obj->date_delivery);
$generic_commande->ref_client = $obj->ref_client;
$generic_commande->total_ht = $obj->total_ht;
$generic_commande->total_tva = $obj->total_tva;
@@ -969,265 +921,20 @@
if (!empty($arrayfields['c.ref']['checked']))
{
print '';
+
+ $generic_commande->getLinesArray(); // This set ->lines
+
print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
- // Warning late icon and note
- if ($generic_commande->hasDelay()) {
- print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
- }
-
- $filename = dol_sanitizeFileName($obj->ref);
- $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
- $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
- print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
-
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Ref customer
- if (!empty($arrayfields['c.ref_client']['checked']))
- {
- print ''.$obj->ref_client.' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Project ref
- if (!empty($arrayfields['p.ref']['checked']))
- {
- print '';
- if ($obj->project_id > 0)
+ // Show shippable Icon (create subloop, so may be slow)
+ if ($conf->stock->enabled)
{
- print $projectstatic->getNomUrl(1);
- }
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Project label
- if (!empty($arrayfields['p.title']['checked']))
- {
- print '';
- if ($obj->project_id > 0)
- {
- print $projectstatic->title;
- }
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Third party
- if (!empty($arrayfields['s.nom']['checked']))
- {
- print '';
- print $getNomUrl_cache[$obj->socid];
-
- // If module invoices enabled and user with invoice creation permissions
- if (!empty($conf->facture->enabled) && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER))
- {
- if ($user->rights->facture->creer)
+ $langs->load("stocks");
+ if (($obj->fk_statut > 0) && ($obj->fk_statut < 3))
{
- if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0))
+ $numlines = count($generic_commande->lines); // Loop on each line of order
+ for ($lig = 0; $lig < $numlines; $lig++)
{
- print ' ';
- print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').' ';
- }
- }
- }
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
- // Town
- if (!empty($arrayfields['s.town']['checked']))
- {
- print '';
- print $obj->town;
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
- // Zip
- if (!empty($arrayfields['s.zip']['checked']))
- {
- print '';
- print $obj->zip;
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
- // State
- if (!empty($arrayfields['state.nom']['checked']))
- {
- print "".$obj->state_name." \n";
- if (!$i) $totalarray['nbfield']++;
- }
- // Country
- if (!empty($arrayfields['country.code_iso']['checked']))
- {
- print '';
- $tmparray = getCountry($obj->fk_pays, 'all');
- print $tmparray['label'];
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
- // Type ent
- if (!empty($arrayfields['typent.code']['checked']))
- {
- print '';
- if (empty($typenArray)) $typenArray = $formcompany->typent_array(1);
- print $typenArray[$obj->typent_code];
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Order date
- if (!empty($arrayfields['c.date_commande']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_commande), 'day');
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
- // Plannned date of delivery
- if (!empty($arrayfields['c.date_delivery']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_delivery), 'dayhour');
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
- // Amount HT
- if (!empty($arrayfields['c.total_ht']['checked']))
- {
- print ''.price($obj->total_ht)." \n";
- if (!$i) $totalarray['nbfield']++;
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht';
- $totalarray['val']['c.total_ht'] += $obj->total_ht;
- }
- // Amount VAT
- if (!empty($arrayfields['c.total_vat']['checked']))
- {
- print ''.price($obj->total_tva)." \n";
- if (!$i) $totalarray['nbfield']++;
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva';
- $totalarray['val']['c.total_tva'] += $obj->total_tva;
- }
- // Amount TTC
- if (!empty($arrayfields['c.total_ttc']['checked']))
- {
- print ''.price($obj->total_ttc)." \n";
- if (!$i) $totalarray['nbfield']++;
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc';
- $totalarray['val']['c.total_ttc'] += $obj->total_ttc;
- }
-
- // Currency
- if (!empty($arrayfields['c.multicurrency_code']['checked']))
- {
- print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)." \n";
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Currency rate
- if (!empty($arrayfields['c.multicurrency_tx']['checked']))
- {
- print '';
- $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
- print " \n";
- if (!$i) $totalarray['nbfield']++;
- }
- // Amount HT
- if (!empty($arrayfields['c.multicurrency_total_ht']['checked']))
- {
- print ''.price($obj->multicurrency_total_ht)." \n";
- if (!$i) $totalarray['nbfield']++;
- }
- // Amount VAT
- if (!empty($arrayfields['c.multicurrency_total_vat']['checked']))
- {
- print ''.price($obj->multicurrency_total_vat)." \n";
- if (!$i) $totalarray['nbfield']++;
- }
- // Amount TTC
- if (!empty($arrayfields['c.multicurrency_total_ttc']['checked']))
- {
- print ''.price($obj->multicurrency_total_ttc)." \n";
- if (!$i) $totalarray['nbfield']++;
- }
-
- $userstatic->id = $obj->fk_user_author;
- $userstatic->login = $obj->login;
-
- // Author
- if (!empty($arrayfields['u.login']['checked']))
- {
- print '';
- if ($userstatic->id) print $userstatic->getLoginUrl(1);
- else print ' ';
- print " \n";
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
-
- // Date creation
- if (!empty($arrayfields['c.datec']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Date modification
- if (!empty($arrayfields['c.tms']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Date cloture
- if (!empty($arrayfields['c.date_cloture']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Note public
- if (!empty($arrayfields['c.note_public']['checked']))
- {
- print '';
- print dol_escape_htmltag($obj->note_public);
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Note private
- if (!empty($arrayfields['c.note_private']['checked']))
- {
- print '';
- print dol_escape_htmltag($obj->note_private);
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
- // Show shippable Icon (this creates subloops, so may be slow)
- if (!empty($arrayfields['shippable']['checked']))
- {
- print '';
- if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) {
- if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
- $generic_commande->getLinesArray(); // This set ->lines
-
- $numlines = count($generic_commande->lines); // Loop on each line of order
- for ($lig = 0; $lig < $numlines; $lig++) {
if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service
{
$nbprod++; // order contains real products
@@ -1235,7 +942,8 @@
// Get local and virtual stock and store it into cache
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
- $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock()
+ $generic_product->load_stock('nobatch');
+ //$generic_product->load_virtual_stock(); Already included into load_stock
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel;
$productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
} else {
@@ -1243,26 +951,26 @@
$generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
}
- if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default should be this case.
+ if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default is when this option is not set, setting it create strange result
{
- $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25);
- $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.' ';
- $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.' ';
+ $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25);
+ $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel;
+ $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique;
$text_info .= ' ';
- if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) {
+ if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel)
+ {
$notshippable++;
}
- } else { // BUGGED CODE.
- // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
- // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
- // Detailed virtual stock, looks bugged, uncomplete and need heavy load.
+ }
+ else { // Detailed code, looks bugged
// stock order and stock order_supplier
$stock_order = 0;
$stock_order_supplier = 0;
if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ?
{
- if (!empty($conf->commande->enabled)) {
+ if (!empty($conf->commande->enabled))
+ {
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) {
$generic_product->load_stats_commande(0, '1,2');
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
@@ -1271,7 +979,8 @@
}
$stock_order = $generic_product->stats_commande['qty'];
}
- if (!empty($conf->fournisseur->enabled)) {
+ if (!empty($conf->fournisseur->enabled))
+ {
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) {
$generic_product->load_stats_commande_fournisseur(0, '3');
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
@@ -1310,16 +1019,246 @@
}
}
- if ($nbprod) {
+ if ($nbprod)
+ {
print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2);
}
if ($warning) { // Always false in default mode
print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').' '.$text_warning, 2, 1, img_picto('', 'error'), '', 2);
}
}
+
+ // Warning late icon and note
+ if ($generic_commande->hasDelay()) {
+ print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
+ }
+
+ $filename = dol_sanitizeFileName($obj->ref);
+ $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
+ $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
+ print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
+
print ' ';
- }
-
+ if (!$i) $totalarray['nbfield']++;
+ }
+
+ // Ref customer
+ if (!empty($arrayfields['c.ref_client']['checked']))
+ {
+ print ''.$obj->ref_client.' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+
+ // Project ref
+ if (!empty($arrayfields['p.ref']['checked']))
+ {
+ print '';
+ if ($obj->project_id > 0)
+ {
+ print $projectstatic->getNomUrl(1);
+ }
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+
+ // Project label
+ if (!empty($arrayfields['p.title']['checked']))
+ {
+ print '';
+ if ($obj->project_id > 0)
+ {
+ print $projectstatic->title;
+ }
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+
+ // Third party
+ if (!empty($arrayfields['s.nom']['checked']))
+ {
+ print '';
+ print $getNomUrl_cache[$obj->socid];
+
+ // If module invoices enabled and user with invoice creation permissions
+ if (!empty($conf->facture->enabled) && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER))
+ {
+ if ($user->rights->facture->creer)
+ {
+ if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0))
+ {
+ print ' ';
+ print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').' ';
+ }
+ }
+ }
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Town
+ if (!empty($arrayfields['s.town']['checked']))
+ {
+ print '';
+ print $obj->town;
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Zip
+ if (!empty($arrayfields['s.zip']['checked']))
+ {
+ print '';
+ print $obj->zip;
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // State
+ if (!empty($arrayfields['state.nom']['checked']))
+ {
+ print "".$obj->state_name." \n";
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Country
+ if (!empty($arrayfields['country.code_iso']['checked']))
+ {
+ print '';
+ $tmparray = getCountry($obj->fk_pays, 'all');
+ print $tmparray['label'];
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Type ent
+ if (!empty($arrayfields['typent.code']['checked']))
+ {
+ print '';
+ if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
+ print $typenArray[$obj->typent_code];
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+
+ // Order date
+ if (!empty($arrayfields['c.date_commande']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_commande), 'day');
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Plannned date of delivery
+ if (!empty($arrayfields['c.date_delivery']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_delivery), 'day');
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Amount HT
+ if (!empty($arrayfields['c.total_ht']['checked']))
+ {
+ print ''.price($obj->total_ht)." \n";
+ if (!$i) $totalarray['nbfield']++;
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht';
+ $totalarray['val']['c.total_ht'] += $obj->total_ht;
+ }
+ // Amount VAT
+ if (!empty($arrayfields['c.total_vat']['checked']))
+ {
+ print ''.price($obj->total_tva)." \n";
+ if (!$i) $totalarray['nbfield']++;
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva';
+ $totalarray['val']['c.total_tva'] += $obj->total_tva;
+ }
+ // Amount TTC
+ if (!empty($arrayfields['c.total_ttc']['checked']))
+ {
+ print ''.price($obj->total_ttc)." \n";
+ if (!$i) $totalarray['nbfield']++;
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc';
+ $totalarray['val']['c.total_ttc'] += $obj->total_ttc;
+ }
+
+ // Currency
+ if (!empty($arrayfields['c.multicurrency_code']['checked']))
+ {
+ print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)." \n";
+ if (!$i) $totalarray['nbfield']++;
+ }
+
+ // Currency rate
+ if (!empty($arrayfields['c.multicurrency_tx']['checked']))
+ {
+ print '';
+ $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
+ print " \n";
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Amount HT
+ if (!empty($arrayfields['c.multicurrency_total_ht']['checked']))
+ {
+ print ''.price($obj->multicurrency_total_ht)." \n";
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Amount VAT
+ if (!empty($arrayfields['c.multicurrency_total_vat']['checked']))
+ {
+ print ''.price($obj->multicurrency_total_vat)." \n";
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Amount TTC
+ if (!empty($arrayfields['c.multicurrency_total_ttc']['checked']))
+ {
+ print ''.price($obj->multicurrency_total_ttc)." \n";
+ if (!$i) $totalarray['nbfield']++;
+ }
+
+ $userstatic->id = $obj->fk_user_author;
+ $userstatic->login = $obj->login;
+
+ // Author
+ if (!empty($arrayfields['u.login']['checked']))
+ {
+ print '';
+ if ($userstatic->id) print $userstatic->getLoginUrl(1);
+ else print ' ';
+ print " \n";
+ if (!$i) $totalarray['nbfield']++;
+ }
+
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Date creation
+ if (!empty($arrayfields['c.datec']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Date modification
+ if (!empty($arrayfields['c.tms']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Date cloture
+ if (!empty($arrayfields['c.date_cloture']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+ // Status
+ if (!empty($arrayfields['c.fk_statut']['checked']))
+ {
+ print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
// Billed
if (!empty($arrayfields['c.facture']['checked']))
{
@@ -1327,15 +1266,8 @@
if (!$i) $totalarray['nbfield']++;
}
- // Status
- if (!empty($arrayfields['c.fk_statut']['checked']))
- {
- print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
// Action column
- print '';
+ print ' ';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0;
@@ -1378,7 +1310,9 @@
$delallowed = $user->rights->commande->creer;
print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
-} else {
+}
+else
+{
dol_print_error($db);
}
--- /tmp/dsg/dolibarr/htdocs/commande/github_note.php
+++ /tmp/dsg/dolibarr/htdocs/commande/client_note.php
@@ -38,7 +38,7 @@
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
-$action = GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'alpha');
// Security check
$socid = 0;
@@ -77,7 +77,7 @@
$head = commande_prepare_head($object);
- print dol_get_fiche_head($head, 'note', $langs->trans("CustomerOrder"), -1, 'order');
+ dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), -1, 'order');
// Order card
@@ -93,36 +93,36 @@
// Project
if (!empty($conf->projet->enabled))
{
- $langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->commande->creer)
- {
- if ($action != 'classify') {
- //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $langs->load("projects");
+ $morehtmlref .= ' '.$langs->trans('Project').' ';
+ if ($user->rights->commande->creer)
+ {
+ if ($action != 'classify') {
+ //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
- }
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= '';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (!empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= '';
- $morehtmlref .= $proj->ref;
- $morehtmlref .= ' ';
- } else {
- $morehtmlref .= '';
- }
- }
+ }
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (!empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= '';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= ' ';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
}
$morehtmlref .= '';
@@ -139,7 +139,7 @@
print '';
- print dol_get_fiche_end();
+ dol_fiche_end();
}