30 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
50 $this->family =
"crm";
51 $this->module_position =
'40';
53 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
57 $this->version =
'dolibarr';
59 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
60 $this->picto =
"dolly";
63 $this->dirs = array(
"/expedition/temp",
64 "/expedition/sending",
65 "/expedition/sending/temp",
66 "/expedition/receipt",
67 "/expedition/receipt/temp",
68 "/doctemplates/shipments",
69 "/doctemplates/deliveries"
73 $this->config_page_url = array(
"confexped.php");
76 $this->depends = array(
"modCommande");
77 $this->requiredby = array();
78 $this->conflictwith = array();
79 $this->langfiles = array(
'deliveries',
'sendings');
82 $this->
const = array();
85 $this->
const[$r][0] =
"EXPEDITION_ADDON_PDF";
86 $this->
const[$r][1] =
"chaine";
87 $this->
const[$r][2] =
"rouget";
88 $this->
const[$r][3] =
'Nom du gestionnaire de generation des bons expeditions en PDF';
89 $this->
const[$r][4] = 0;
92 $this->
const[$r][0] =
"EXPEDITION_ADDON_NUMBER";
93 $this->
const[$r][1] =
"chaine";
94 $this->
const[$r][2] =
"mod_expedition_safor";
95 $this->
const[$r][3] =
'Name for numbering manager for shipments';
96 $this->
const[$r][4] = 0;
99 $this->
const[$r][0] =
"EXPEDITION_ADDON_PDF_ODT_PATH";
100 $this->
const[$r][1] =
"chaine";
101 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/shipments";
102 $this->
const[$r][3] =
"";
103 $this->
const[$r][4] = 0;
106 $this->
const[$r][0] =
"DELIVERY_ADDON_PDF";
107 $this->
const[$r][1] =
"chaine";
108 $this->
const[$r][2] =
"typhon";
109 $this->
const[$r][3] =
'Nom du gestionnaire de generation des bons de reception en PDF';
110 $this->
const[$r][4] = 0;
113 $this->
const[$r][0] =
"DELIVERY_ADDON_NUMBER";
114 $this->
const[$r][1] =
"chaine";
115 $this->
const[$r][2] =
"mod_delivery_jade";
116 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des bons de reception';
117 $this->
const[$r][4] = 0;
120 $this->
const[$r][0] =
"DELIVERY_ADDON_PDF_ODT_PATH";
121 $this->
const[$r][1] =
"chaine";
122 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/deliveries";
123 $this->
const[$r][3] =
"";
124 $this->
const[$r][4] = 0;
127 $this->
const[$r][0] =
"MAIN_SUBMODULE_EXPEDITION";
128 $this->
const[$r][1] =
"chaine";
129 $this->
const[$r][2] =
"1";
130 $this->
const[$r][3] =
"Enable delivery receipts";
131 $this->
const[$r][4] = 0;
135 $this->boxes = array(
136 0=>array(
'file'=>
'box_shipments.php',
'enabledbydefaulton'=>
'Home'),
140 $this->rights = array();
141 $this->rights_class =
'expedition';
145 $this->rights[$r][0] = 101;
146 $this->rights[$r][1] =
'Lire les expeditions';
147 $this->rights[$r][2] =
'r';
148 $this->rights[$r][3] = 0;
149 $this->rights[$r][4] =
'lire';
152 $this->rights[$r][0] = 102;
153 $this->rights[$r][1] =
'Creer modifier les expeditions';
154 $this->rights[$r][2] =
'w';
155 $this->rights[$r][3] = 0;
156 $this->rights[$r][4] =
'creer';
159 $this->rights[$r][0] = 104;
160 $this->rights[$r][1] =
'Valider les expeditions';
161 $this->rights[$r][2] =
'd';
162 $this->rights[$r][3] = 0;
163 $this->rights[$r][4] =
'shipping_advance';
164 $this->rights[$r][5] =
'validate';
167 $this->rights[$r][0] = 105;
168 $this->rights[$r][1] =
'Envoyer les expeditions aux clients';
169 $this->rights[$r][2] =
'd';
170 $this->rights[$r][3] = 0;
171 $this->rights[$r][4] =
'shipping_advance';
172 $this->rights[$r][5] =
'send';
175 $this->rights[$r][0] = 106;
176 $this->rights[$r][1] =
'Exporter les expeditions';
177 $this->rights[$r][2] =
'r';
178 $this->rights[$r][3] = 0;
179 $this->rights[$r][4] =
'shipment';
180 $this->rights[$r][5] =
'export';
183 $this->rights[$r][0] = 109;
184 $this->rights[$r][1] =
'Supprimer les expeditions';
185 $this->rights[$r][2] =
'd';
186 $this->rights[$r][3] = 0;
187 $this->rights[$r][4] =
'supprimer';
190 $this->rights[$r][0] = 1101;
191 $this->rights[$r][1] =
'Read delivery receipts';
192 $this->rights[$r][2] =
'r';
193 $this->rights[$r][3] = 0;
194 $this->rights[$r][4] =
'delivery';
195 $this->rights[$r][5] =
'lire';
198 $this->rights[$r][0] = 1102;
199 $this->rights[$r][1] =
'Create/modify delivery receipts';
200 $this->rights[$r][2] =
'w';
201 $this->rights[$r][3] = 0;
202 $this->rights[$r][4] =
'delivery';
203 $this->rights[$r][5] =
'creer';
206 $this->rights[$r][0] = 1104;
207 $this->rights[$r][1] =
'Validate delivery receipts';
208 $this->rights[$r][2] =
'd';
209 $this->rights[$r][3] = 0;
210 $this->rights[$r][4] =
'delivery_advance';
211 $this->rights[$r][5] =
'validate';
214 $this->rights[$r][0] = 1109;
215 $this->rights[$r][1] =
'Delete delivery receipts';
216 $this->rights[$r][2] =
'd';
217 $this->rights[$r][3] = 0;
218 $this->rights[$r][4] =
'delivery';
219 $this->rights[$r][5] =
'supprimer';
231 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
233 $contact_arrays = $shipment->liste_type_contact(
'external',
'', 0, 0,
'');
234 if (is_array($contact_arrays) && count($contact_arrays) > 0) {
235 $idcontacts = join(
',', array_keys($shipment->liste_type_contact(
'external',
'', 0, 0,
'')));
242 $this->export_code[$r] = $this->rights_class.
'_'.$r;
243 $this->export_label[$r] =
'Shipments';
244 $this->export_permission[$r] = array(array(
"expedition",
"shipment",
"export"));
245 $this->export_fields_array[$r] = array(
246 's.rowid'=>
"IdCompany",
's.nom'=>
'ThirdParty',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'd.nom'=>
'State',
'co.label'=>
'Country',
247 'co.code'=>
'CountryCode',
's.phone'=>
'Phone',
's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
248 's.idprof6'=>
'ProfId6',
'c.rowid'=>
"Id",
'c.ref'=>
"Ref",
'c.ref_customer'=>
"RefCustomer",
'c.fk_soc'=>
"IdCompany",
'c.date_creation'=>
"DateCreation",
249 'c.date_delivery'=>
"DateDeliveryPlanned",
'c.tracking_number'=>
"TrackingNumber",
'c.height'=>
"Height",
'c.width'=>
"Width",
'c.size'=>
"Depth",
250 'c.size_units'=>
'SizeUnits',
'c.weight'=>
"Weight",
'c.weight_units'=>
"WeightUnits",
'c.fk_statut'=>
'Status',
'c.note_public'=>
"NotePublic",
251 'ed.rowid'=>
'LineId',
'cd.description'=>
'Description',
'ed.qty'=>
"Qty",
'p.rowid'=>
'ProductId',
'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
252 'p.weight'=>
'ProductWeight',
'p.weight_units'=>
'WeightUnits',
'p.volume'=>
'ProductVolume',
'p.volume_units'=>
'VolumeUnits'
254 if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r] += array(
'sp.rowid'=>
'IdContact',
'sp.lastname'=>
'Lastname',
'sp.firstname'=>
'Firstname',
'sp.note_public'=>
'NotePublic');
261 $this->export_TypeFields_array[$r] = array(
262 's.nom'=>
'Text',
's.address'=>
'Text',
's.zip'=>
'Text',
's.town'=>
'Text',
'co.label'=>
'List:c_country:label:label',
'co.code'=>
'Text',
's.phone'=>
'Text',
263 's.siren'=>
'Text',
's.siret'=>
'Text',
's.ape'=>
'Text',
's.idprof4'=>
'Text',
'c.ref'=>
"Text",
'c.ref_customer'=>
"Text",
'c.date_creation'=>
"Date",
264 'c.date_delivery'=>
"Date",
'c.tracking_number'=>
"Numeric",
'c.height'=>
"Numeric",
'c.width'=>
"Numeric",
'c.weight'=>
"Numeric",
'c.fk_statut'=>
'Status',
265 'c.note_public'=>
"Text",
'ed.qty'=>
"Numeric",
'd.nom'=>
'Text'
267 $this->export_entities_array[$r] = array(
268 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'd.nom'=>
'company',
'co.label'=>
'company',
269 'co.code'=>
'company',
's.fk_pays'=>
'company',
's.phone'=>
'company',
's.siren'=>
'company',
's.ape'=>
'company',
's.siret'=>
'company',
's.idprof4'=>
'company',
270 's.idprof5'=>
'company',
's.idprof6'=>
'company',
'c.rowid'=>
"shipment",
'c.ref'=>
"shipment",
'c.ref_customer'=>
"shipment",
'c.fk_soc'=>
"shipment",
271 'c.date_creation'=>
"shipment",
'c.date_delivery'=>
"shipment",
'c.tracking_number'=>
'shipment',
'c.height'=>
"shipment",
'c.width'=>
"shipment",
272 'c.size'=>
'shipment',
'c.size_units'=>
'shipment',
'c.weight'=>
"shipment",
'c.weight_units'=>
'shipment',
'c.fk_statut'=>
"shipment",
'c.note_public'=>
"shipment",
273 'ed.rowid'=>
'shipment_line',
'cd.description'=>
'shipment_line',
'ed.qty'=>
"shipment_line",
'p.rowid'=>
'product',
'p.ref'=>
'product',
'p.label'=>
'product',
274 'p.weight'=>
'product',
'p.weight_units'=>
'product',
'p.volume'=>
'product',
'p.volume_units'=>
'product'
276 if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array(
'sp.rowid'=>
'contact',
'sp.lastname'=>
'contact',
'sp.firstname'=>
'contact',
'sp.note_public'=>
'contact');
277 $this->export_dependencies_array[$r] = array(
'shipment_line'=>
'ed.rowid',
'product'=>
'ed.rowid');
278 if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
280 $keyforselect =
'socpeople'; $keyforelement =
'contact'; $keyforaliasextra =
'extra3';
281 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
283 $keyforselect =
'expedition'; $keyforelement =
'shipment'; $keyforaliasextra =
'extra';
284 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
285 $keyforselect =
'expeditiondet'; $keyforelement =
'shipment_line'; $keyforaliasextra =
'extra2';
286 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
287 $keyforselect =
'product'; $keyforelement =
'product'; $keyforaliasextra =
'extraprod';
288 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
290 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
291 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'expedition as c';
292 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
293 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'societe as s';
294 if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
295 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON s.fk_departement = d.rowid';
296 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co ON s.fk_pays = co.rowid,';
297 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'expeditiondet as ed';
298 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object';
299 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'commandedet as cd';
300 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on cd.fk_product = p.rowid';
301 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extraprod ON p.rowid = extraprod.fk_object';
302 if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) {
303 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.
')';
304 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople as sp ON sp.rowid = ee.fk_socpeople';
305 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
307 $this->export_sql_end[$r] .=
' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
308 $this->export_sql_end[$r] .=
' AND c.entity IN ('.getEntity(
'expedition').
')';
309 if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
321 public function init($options =
'')
323 global $conf, $langs;
326 $this->
remove($options);
329 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/shipments/template_shipment.odt';
330 $dirodt = DOL_DATA_ROOT.
'/doctemplates/shipments';
331 $dest = $dirodt.
'/template_shipment.odt';
333 if (file_exists($src) && !file_exists($dest))
335 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
337 $result =
dol_copy($src, $dest, 0, 0);
340 $langs->load(
"errors");
341 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
349 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = '".$this->db->escape($this->const[0][2]).
"' AND type = 'shipping' AND entity = ".$conf->entity,
350 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->
db->escape($this->
const[0][2]).
"','shipping',".$conf->entity.
")",
351 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = '".$this->
db->escape($this->
const[3][2]).
"' AND type = 'delivery' AND entity = ".$conf->entity,
352 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->
db->escape($this->
const[3][2]).
"','delivery',".$conf->entity.
")",
355 return $this->
_init($sql, $options);
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
Class to manage customers orders.
Class to describe and enable module Expedition.
init($options= '')
Function called when module is enabled.
_init($array_sql, $options= '')
Enables a module.
__construct($db)
Constructor.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)