52 $this->family =
"crm";
53 $this->module_position =
'40';
55 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
59 $this->version =
'dolibarr';
61 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
62 $this->picto =
"dolly";
65 $this->dirs = array(
"/expedition/temp",
66 "/expedition/sending",
67 "/expedition/sending/temp",
68 "/expedition/receipt",
69 "/expedition/receipt/temp",
70 "/doctemplates/shipments",
71 "/doctemplates/deliveries"
75 $this->config_page_url = array(
"expedition.php");
78 $this->depends = array(
"modCommande");
79 $this->requiredby = array();
80 $this->conflictwith = array();
81 $this->langfiles = array(
'deliveries',
'sendings');
84 $this->
const = array();
87 $this->
const[$r][0] =
"EXPEDITION_ADDON_PDF";
88 $this->
const[$r][1] =
"chaine";
89 $this->
const[$r][2] =
"espadon";
90 $this->
const[$r][3] =
'Nom du gestionnaire de generation des bons expeditions en PDF';
91 $this->
const[$r][4] = 0;
94 $this->
const[$r][0] =
"EXPEDITION_ADDON_NUMBER";
95 $this->
const[$r][1] =
"chaine";
96 $this->
const[$r][2] =
"mod_expedition_safor";
97 $this->
const[$r][3] =
'Name for numbering manager for shipments';
98 $this->
const[$r][4] = 0;
101 $this->
const[$r][0] =
"EXPEDITION_ADDON_PDF_ODT_PATH";
102 $this->
const[$r][1] =
"chaine";
103 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/shipments";
104 $this->
const[$r][3] =
"";
105 $this->
const[$r][4] = 0;
108 $this->
const[$r][0] =
"DELIVERY_ADDON_PDF";
109 $this->
const[$r][1] =
"chaine";
110 $this->
const[$r][2] =
"storm";
111 $this->
const[$r][3] =
'Nom du gestionnaire de generation des bons de reception en PDF';
112 $this->
const[$r][4] = 0;
115 $this->
const[$r][0] =
"DELIVERY_ADDON_NUMBER";
116 $this->
const[$r][1] =
"chaine";
117 $this->
const[$r][2] =
"mod_delivery_jade";
118 $this->
const[$r][3] =
'Nom du gestionnaire de numerotation des bons de reception';
119 $this->
const[$r][4] = 0;
122 $this->
const[$r][0] =
"DELIVERY_ADDON_PDF_ODT_PATH";
123 $this->
const[$r][1] =
"chaine";
124 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/deliveries";
125 $this->
const[$r][3] =
"";
126 $this->
const[$r][4] = 0;
129 $this->
const[$r][0] =
"MAIN_SUBMODULE_EXPEDITION";
130 $this->
const[$r][1] =
"chaine";
131 $this->
const[$r][2] =
"1";
132 $this->
const[$r][3] =
"Enable delivery receipts";
133 $this->
const[$r][4] = 0;
137 $this->boxes = array(
138 0=>array(
'file'=>
'box_shipments.php',
'enabledbydefaulton'=>
'Home'),
142 $this->rights = array();
143 $this->rights_class =
'expedition';
147 $this->rights[$r][0] = 101;
148 $this->rights[$r][1] =
'Read shipments';
149 $this->rights[$r][2] =
'r';
150 $this->rights[$r][3] = 0;
151 $this->rights[$r][4] =
'lire';
154 $this->rights[$r][0] = 102;
155 $this->rights[$r][1] =
'Create/modify shipments';
156 $this->rights[$r][2] =
'w';
157 $this->rights[$r][3] = 0;
158 $this->rights[$r][4] =
'creer';
161 $this->rights[$r][0] = 104;
162 $this->rights[$r][1] =
'Validate shipments';
163 $this->rights[$r][2] =
'd';
164 $this->rights[$r][3] = 0;
165 $this->rights[$r][4] =
'shipping_advance';
166 $this->rights[$r][5] =
'validate';
169 $this->rights[$r][0] = 105;
170 $this->rights[$r][1] =
'Send shipments by email to customers';
171 $this->rights[$r][2] =
'd';
172 $this->rights[$r][3] = 0;
173 $this->rights[$r][4] =
'shipping_advance';
174 $this->rights[$r][5] =
'send';
177 $this->rights[$r][0] = 106;
178 $this->rights[$r][1] =
'Export shipments';
179 $this->rights[$r][2] =
'r';
180 $this->rights[$r][3] = 0;
181 $this->rights[$r][4] =
'shipment';
182 $this->rights[$r][5] =
'export';
185 $this->rights[$r][0] = 109;
186 $this->rights[$r][1] =
'Delete shipments';
187 $this->rights[$r][2] =
'd';
188 $this->rights[$r][3] = 0;
189 $this->rights[$r][4] =
'supprimer';
192 $this->rights[$r][0] = 1101;
193 $this->rights[$r][1] =
'Read delivery receipts';
194 $this->rights[$r][2] =
'r';
195 $this->rights[$r][3] = 0;
196 $this->rights[$r][4] =
'delivery';
197 $this->rights[$r][5] =
'lire';
200 $this->rights[$r][0] = 1102;
201 $this->rights[$r][1] =
'Create/modify delivery receipts';
202 $this->rights[$r][2] =
'w';
203 $this->rights[$r][3] = 0;
204 $this->rights[$r][4] =
'delivery';
205 $this->rights[$r][5] =
'creer';
208 $this->rights[$r][0] = 1104;
209 $this->rights[$r][1] =
'Validate delivery receipts';
210 $this->rights[$r][2] =
'd';
211 $this->rights[$r][3] = 0;
212 $this->rights[$r][4] =
'delivery_advance';
213 $this->rights[$r][5] =
'validate';
216 $this->rights[$r][0] = 1109;
217 $this->rights[$r][1] =
'Delete delivery receipts';
218 $this->rights[$r][2] =
'd';
219 $this->rights[$r][3] = 0;
220 $this->rights[$r][4] =
'delivery';
221 $this->rights[$r][5] =
'supprimer';
233 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
234 $shipment =
new Commande($this->db);
235 $contact_arrays = $shipment->liste_type_contact(
'external',
'', 0, 0,
'');
236 if (is_array($contact_arrays) && count($contact_arrays) > 0) {
237 $idcontacts = implode(
',', array_keys($shipment->liste_type_contact(
'external',
'', 0, 0,
'')));
244 $this->export_code[$r] = $this->rights_class.
'_'.$r;
245 $this->export_label[$r] =
'Shipments';
246 $this->export_permission[$r] = array(array(
"expedition",
"shipment",
"export"));
247 $this->export_fields_array[$r] = array(
248 's.rowid'=>
"IdCompany",
's.nom'=>
'ThirdParty',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'd.nom'=>
'State',
'co.label'=>
'Country',
249 'co.code'=>
'CountryCode',
's.phone'=>
'Phone',
's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.idprof5'=>
'ProfId5',
250 's.idprof6'=>
'ProfId6',
'c.rowid'=>
"Id",
'c.ref'=>
"Ref",
'c.ref_customer'=>
"RefCustomer",
'c.fk_soc'=>
"IdCompany",
'c.date_creation'=>
"DateCreation",
'c.date_valid'=>
"DateValidation",
251 'c.date_delivery'=>
"DateDeliveryPlanned",
'c.tracking_number'=>
"TrackingNumber",
'c.height'=>
"Height",
'c.width'=>
"Width",
'c.size'=>
"Depth",
252 'c.size_units'=>
'SizeUnits',
'c.weight'=>
"Weight",
'c.weight_units'=>
"WeightUnits",
'c.fk_statut'=>
'Status',
'c.note_public'=>
"NotePublic",
253 'ed.rowid'=>
'LineId',
'cd.description'=>
'Description',
'ed.qty'=>
"Qty",
'p.rowid'=>
'ProductId',
'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
254 'p.weight'=>
'ProductWeight',
'p.weight_units'=>
'WeightUnits',
'p.volume'=>
'ProductVolume',
'p.volume_units'=>
'VolumeUnits'
257 $this->export_fields_array[$r] += array(
'sp.rowid'=>
'IdContact',
'sp.lastname'=>
'Lastname',
'sp.firstname'=>
'Firstname',
'sp.note_public'=>
'NotePublic');
265 $this->export_TypeFields_array[$r] = array(
266 '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',
267 's.siren'=>
'Text',
's.siret'=>
'Text',
's.ape'=>
'Text',
's.idprof4'=>
'Text',
'c.ref'=>
"Text",
'c.ref_customer'=>
"Text",
'c.date_creation'=>
"Date",
'c.date_valid'=>
"Date",
268 'c.date_delivery'=>
"Date",
'c.tracking_number'=>
"Numeric",
'c.height'=>
"Numeric",
'c.width'=>
"Numeric",
'c.weight'=>
"Numeric",
'c.fk_statut'=>
'Status',
269 'c.note_public'=>
"Text",
'ed.qty'=>
"Numeric",
'd.nom'=>
'Text'
271 $this->export_entities_array[$r] = array(
272 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'd.nom'=>
'company',
'co.label'=>
'company',
273 'co.code'=>
'company',
's.fk_pays'=>
'company',
's.phone'=>
'company',
's.siren'=>
'company',
's.ape'=>
'company',
's.siret'=>
'company',
's.idprof4'=>
'company',
274 's.idprof5'=>
'company',
's.idprof6'=>
'company',
'c.rowid'=>
"shipment",
'c.ref'=>
"shipment",
'c.ref_customer'=>
"shipment",
'c.fk_soc'=>
"shipment",
275 'c.date_creation'=>
"shipment",
'c.date_valid'=>
"shipment",
'c.date_delivery'=>
"shipment",
'c.tracking_number'=>
'shipment',
'c.height'=>
"shipment",
'c.width'=>
"shipment",
276 'c.size'=>
'shipment',
'c.size_units'=>
'shipment',
'c.weight'=>
"shipment",
'c.weight_units'=>
'shipment',
'c.fk_statut'=>
"shipment",
'c.note_public'=>
"shipment",
277 'ed.rowid'=>
'shipment_line',
'cd.description'=>
'shipment_line',
'ed.qty'=>
"shipment_line",
'p.rowid'=>
'product',
'p.ref'=>
'product',
'p.label'=>
'product',
278 'p.weight'=>
'product',
'p.weight_units'=>
'product',
'p.volume'=>
'product',
'p.volume_units'=>
'product'
281 $this->export_entities_array[$r] += array(
'sp.rowid'=>
'contact',
'sp.lastname'=>
'contact',
'sp.firstname'=>
'contact',
'sp.note_public'=>
'contact');
283 $this->export_dependencies_array[$r] = array(
'shipment_line'=>
'ed.rowid',
'product'=>
'ed.rowid');
285 $keyforselect =
'socpeople';
286 $keyforelement =
'contact';
287 $keyforaliasextra =
'extra3';
288 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
290 $keyforselect =
'expedition';
291 $keyforelement =
'shipment';
292 $keyforaliasextra =
'extra';
293 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
294 $keyforselect =
'expeditiondet';
295 $keyforelement =
'shipment_line';
296 $keyforaliasextra =
'extra2';
297 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
298 $keyforselect =
'product';
299 $keyforelement =
'product';
300 $keyforaliasextra =
'extraprod';
301 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
303 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
304 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'expedition as c';
305 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
306 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'societe as s';
307 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
308 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
310 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as d ON s.fk_departement = d.rowid';
311 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co ON s.fk_pays = co.rowid,';
312 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'expeditiondet as ed';
313 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object';
314 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'commandedet as cd';
315 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on cd.fk_product = p.rowid';
316 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extraprod ON p.rowid = extraprod.fk_object';
318 $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 ('.$this->db->sanitize($idcontacts).
')';
319 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople as sp ON sp.rowid = ee.fk_socpeople';
320 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
322 $this->export_sql_end[$r] .=
' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_elementdet = cd.rowid';
323 $this->export_sql_end[$r] .=
' AND c.entity IN ('.getEntity(
'expedition').
')';
324 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
325 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);