diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 3988a986f67..62b251ac01d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -124,6 +124,14 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } + // customer preferred shipping method + if ($action == 'setshippingmethod' && $user->rights->societe->creer) + { + $object->fetch($id); + $result = $object->setShippingMethod(GETPOST('shipping_method_id','int')); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + } + // assujetissement a la TVA if ($action == 'setassujtva' && $user->rights->societe->creer) { @@ -239,8 +247,8 @@ if ($id > 0) if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans("Prefix").''; - print ($object->prefix_comm?$object->prefix_comm:' '); - print ''; + print ($object->prefix_comm?$object->prefix_comm:' '); + print ''; } if ($object->client) @@ -431,6 +439,27 @@ if ($id > 0) print ''; } + // Preferred shipping Method + if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) { + print ''; + print ''; + print '
'; + print $langs->trans('SendingMethod'); + print ''; + if (($action != 'editshipping') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; + print ''; + if ($action == 'editshipping') + { + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->shipping_method_id,'shipping_method_id'); + } + else + { + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->shipping_method_id,'none'); + } + print ""; + print ''; + } + // Categories if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { print '' . $langs->trans( "Categories" ) . ''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index c1754999e8b..dea894a0258 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1320,6 +1320,9 @@ if ($action == 'create') print $soc->getNomUrl(1); print ''; print ''; + if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && ! empty($soc->shipping_method_id)) { + $shipping_method_id = $soc->shipping_method_id; + } } else { print ''; print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 1); diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index eb0a203fa92..d9898fbe3c0 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -180,6 +180,7 @@ CREATE TABLE llx_multicurrency_rate ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer; ALTER TABLE llx_societe ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_societe ADD COLUMN fk_shipping_method integer AFTER cond_reglement_supplier; ALTER TABLE llx_product_price ADD COLUMN fk_multicurrency integer; ALTER TABLE llx_product_price ADD COLUMN multicurrency_code varchar(255); diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 82e3b420e29..9822272e7c2 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -85,6 +85,7 @@ create table llx_societe cond_reglement tinyint, -- condition de reglement mode_reglement_supplier tinyint, -- mode de reglement fournisseur cond_reglement_supplier tinyint, -- condition de reglement fournisseur + fk_shipping_method integer, -- preferred shipping method id tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1 localtax1_value double(6,3), diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 265882345ac..3468dc43eee 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1114,6 +1114,7 @@ BrowserIsKO=You are using the web browser %s. This browser is known to be a bad XDebugInstalled=XDebug is loaded. XCacheInstalled=XCache is loaded. AddRefInList=Display customer/supplier ref into list (select list or combobox) and most of hyperlink. Third parties will appears with name "CC12345 - SC45678 - The big company coorp", instead of "The big company coorp". +AskForPreferredShippingMethod=Ask for preferred Sending Method for Third Parties. FieldEdition=Edition of field %s FillThisOnlyIfRequired=Example: +2 (fill only if timezone offset problems are experienced) GetBarCode=Get barcode diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index e69d098ea7d..8e7fe40859b 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -225,6 +225,20 @@ if ($action=="setaddrefinlist") { } } +//Activate Ask For Preferred Shipping Method +if ($action=="setaskforshippingmet") { + $setaskforshippingmet = GETPOST('value','int'); + $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet,'yesno',0,'',$conf->entity); + if (! $res > 0) $error++; + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} //Activate ProfId mandatory if ($action == 'setprofidmandatory') @@ -777,6 +791,26 @@ print ''; print ''; +$var=!$var; +print ""; +print ''.$langs->trans("AskForPreferredShippingMethod").''; +print ' '; +print ''; +if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) +{ + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); + +} +else +{ + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); +} +print ''; +print ''; + + /* // COMPANY_USE_SEARCH_TO_SELECT $var=!$var; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 13d6d7dcde8..1005b8c3c8d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -840,6 +840,7 @@ class Societe extends CommonObject $sql .= ",cond_reglement = ".(! empty($this->cond_reglement_id)?"'".$this->db->escape($this->cond_reglement_id)."'":"null"); $sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null"); $sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null"); + $sql .= ", fk_shipping_method_id = ".(! empty($this->shipping_method_id)?"'".$this->db->escape($this->shipping_method_id)."'":"null"); $sql .= ",client = " . (! empty($this->client)?$this->client:0); $sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0); @@ -1018,6 +1019,7 @@ class Societe extends CommonObject $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo'; + $sql .= ', s.fk_shipping_method'; $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; $sql .= ', s.fk_multicurrency, s.multicurrency_code'; $sql .= ', fj.libelle as forme_juridique'; @@ -1144,6 +1146,7 @@ class Societe extends CommonObject $this->cond_reglement_id = $obj->cond_reglement; $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; + $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; $this->client = $obj->client; $this->fournisseur = $obj->fournisseur;