26require_once DOL_DOCUMENT_ROOT .
'/expedition/class/expedition.class.php';
27require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
28require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
49 foreach (
$object->lines as $line) {
50 if ((
int) $line->fk_expedition !== (
int)
$object->id) {
53 if ((
int) $line->id === $sourceLineId) {
56 if ((
int) $line->id === $lineId) {
57 $dispatchLine = $line;
61 if ($sourceLine ===
null || $sourceLine->fk_parent > 0 || (
int) $sourceLine->fk_product !== $productId) {
64 if ($lineId > 0 && ($dispatchLine ===
null || (
int) $dispatchLine->fk_product !== $productId
65 || ($lineId !== $sourceLineId && (
int) $dispatchLine->fk_parent !== $sourceLineId))) {
81 global $db, $langs,
$conf, $user;
84 $langs->loadLangs(array(
"sendings"));
89 $head[$h][0] = DOL_URL_ROOT .
"/expedition/card.php?id=" .
$object->id;
90 $head[$h][1] = $langs->trans(
"SendingCard");
91 $head[$h][2] =
'shipping';
95 $head[$h][0] = DOL_URL_ROOT .
"/expedition/dispatch.php?id=" .
$object->id;
96 $head[$h][1] = $langs->trans(
"ShipmentDistribution");
97 $head[$h][2] =
'dispatch';
101 if (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'lire')) {
104 if (isset(
$object->linkedObjectsIds[
'delivery']) && is_array(
$object->linkedObjectsIds[
'delivery']) && count(
$object->linkedObjectsIds[
'delivery']) > 0) {
106 $tmp = reset(
$object->linkedObjectsIds[
'delivery']);
108 $head[$h][0] = DOL_URL_ROOT .
"/delivery/card.php?id=" . ((int) $tmp);
109 $head[$h][1] = $langs->trans(
"DeliveryCard");
110 $head[$h][2] =
'delivery';
119 $objectsrc->fetch(
$object->origin_id);
121 $nbContact = count($objectsrc->liste_contact(-1,
'internal')) + count($objectsrc->liste_contact(-1,
'external'));
122 $head[$h][0] = DOL_URL_ROOT .
"/expedition/contact.php?id=" . ((int)
$object->id);
123 $head[$h][1] = $langs->trans(
"ContactsAddresses");
124 if ($nbContact > 0) {
125 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbContact .
'</span>';
127 $head[$h][2] =
'contact';
132 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
133 require_once DOL_DOCUMENT_ROOT .
'/core/class/link.class.php';
135 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
137 $head[$h][0] = DOL_URL_ROOT .
'/expedition/document.php?id=' .
$object->id;
138 $head[$h][1] = $langs->trans(
'Documents');
139 if (($nbFiles + $nbLinks) > 0) {
140 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) .
'</span>';
142 $head[$h][2] =
'documents';
147 if (!empty(
$object->note_private)) {
150 if (!empty(
$object->note_public)) {
153 $head[$h][0] = DOL_URL_ROOT .
"/expedition/note.php?id=" .
$object->id;
154 $head[$h][1] = $langs->trans(
"Notes");
156 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>';
158 $head[$h][2] =
'note';
162 $head[$h][0] = DOL_URL_ROOT .
'/expedition/agenda.php?id=' .
$object->id;
163 $head[$h][1] = $langs->trans(
"Events");
164 if (
isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
167 require_once DOL_DOCUMENT_ROOT .
'/core/lib/memory.lib.php';
168 $cachekey =
'count_events_expedition_' .
$object->id;
170 if (!is_null($dataretrieved)) {
171 $nbEvent = $dataretrieved;
173 $sql =
"SELECT COUNT(id) as nb";
174 $sql .=
" FROM " . MAIN_DB_PREFIX .
"actioncomm";
175 $sql .=
" WHERE fk_element = " . ((int)
$object->id);
176 $sql .=
" AND elementtype = 'shipping'";
177 $resql = $db->query($sql);
179 $obj = $db->fetch_object($resql);
182 dol_syslog(
'Failed to count actioncomm ' . $db->lasterror(), LOG_ERR);
188 $head[$h][1] .= $langs->trans(
"Agenda");
190 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbEvent .
'</span>';
193 $head[$h][2] =
'agenda';
216 global $langs, $db,
$conf, $user;
219 $langs->loadLangs(array(
"sendings"));
224 if (
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'lire')) {
225 $head[$h][0] = DOL_URL_ROOT .
"/expedition/card.php?id=" .
$object->origin_id;
226 $head[$h][1] = $langs->trans(
"SendingCard");
227 $head[$h][2] =
'shipping';
231 $head[$h][0] = DOL_URL_ROOT .
"/delivery/card.php?id=" .
$object->id;
232 $head[$h][1] = $langs->trans(
"DeliveryCard");
233 $head[$h][2] =
'delivery';
248 $tmpobject->fetch(
$object->origin_id);
254 $objectsrc = $tmpobject;
255 if ($tmpobject->origin_type ==
'commande' && $tmpobject->origin_id > 0) {
257 $objectsrc->fetch($tmpobject->origin_id);
259 $nbContact = count($objectsrc->liste_contact(-1,
'internal')) + count($objectsrc->liste_contact(-1,
'external'));
260 $head[$h][0] = DOL_URL_ROOT .
"/expedition/contact.php?id=" . $tmpobject->id;
261 $head[$h][1] = $langs->trans(
"ContactsAddresses");
262 if ($nbContact > 0) {
263 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbContact .
'</span>';
265 $head[$h][2] =
'contact';
270 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
271 require_once DOL_DOCUMENT_ROOT .
'/core/class/link.class.php';
273 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
274 $nbLinks =
Link::count($db, $tmpobject->element, $tmpobject->id);
275 $head[$h][0] = DOL_URL_ROOT .
'/expedition/document.php?id=' . $tmpobject->id;
276 $head[$h][1] = $langs->trans(
'Documents');
277 if (($nbFiles + $nbLinks) > 0) {
278 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) .
'</span>';
280 $head[$h][2] =
'documents';
285 if (!empty($tmpobject->note_private)) {
288 if (!empty($tmpobject->note_public)) {
291 $head[$h][0] = DOL_URL_ROOT .
"/expedition/note.php?id=" . $tmpobject->id;
292 $head[$h][1] = $langs->trans(
"Notes");
294 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>';
296 $head[$h][2] =
'note';
300 $head[$h][0] = DOL_URL_ROOT .
'/expedition/agenda.php?id=' . $tmpobject->id;
301 $head[$h][1] = $langs->trans(
"Events");
302 if (
isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
305 require_once DOL_DOCUMENT_ROOT .
'/core/lib/memory.lib.php';
306 $cachekey =
'count_events_expedition_' . $tmpobject->id;
308 if (!is_null($dataretrieved)) {
309 $nbEvent = $dataretrieved;
311 $sql =
"SELECT COUNT(id) as nb";
312 $sql .=
" FROM " . MAIN_DB_PREFIX .
"actioncomm";
313 $sql .=
" WHERE fk_element = " . ((int) $tmpobject->id);
314 $sql .=
" AND elementtype = 'shipping'";
315 $resql = $db->query($sql);
317 $obj = $db->fetch_object($resql);
320 dol_syslog(
'Failed to count actioncomm ' . $db->lasterror(), LOG_ERR);
326 $head[$h][1] .= $langs->trans(
"Agenda");
328 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbEvent .
'</span>';
331 $head[$h][2] =
'agenda';
353function show_list_sending_receive($origin, $origin_id, $filter =
'')
355 global $db,
$conf, $langs;
358 $product_static =
new Product($db);
360 $warehousestatic =
new Entrepot($db);
362 $sql =
"SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end, obj.special_code,";
363 $sql .=
" ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot as warehouse_id,";
364 $sql .=
" e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition, e.billed, e.fk_statut as status, e.signed_status,";
365 $sql .=
' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,';
366 $sql .=
' p.description as product_desc';
367 $sql .=
" FROM " . MAIN_DB_PREFIX .
"expeditiondet as ed,";
368 $sql .=
" " . MAIN_DB_PREFIX .
"expedition as e,";
369 $sql .=
" " . MAIN_DB_PREFIX . $db->sanitize($origin) .
"det as obj";
370 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product as p ON obj.fk_product = p.rowid";
372 $sql .=
" WHERE e.entity IN (" .
getEntity(
'expedition') .
")";
373 $sql .=
" AND obj.fk_" . $db->sanitize($origin) .
" = " . ((int) $origin_id);
374 $sql .=
" AND obj.rowid = ed.fk_elementdet";
376 $sql .=
" AND obj.special_code <> " . SUBTOTALS_SPECIAL_CODE;
378 $sql .=
" AND ed.fk_expedition = e.rowid";
382 $sql .=
" ORDER BY obj.rowid, obj.fk_product";
384 dol_syslog(
"show_list_sending_receive", LOG_DEBUG);
385 $resql = $db->query($sql);
387 $num = $db->num_rows($resql);
397 print
'<div class="div-table-responsive-no-min">';
398 print
'<table class="liste centpercent">';
399 print
'<tr class="liste_titre">';
401 print
'<td>' . $langs->trans(
"SendingSheet") .
'</td>';
402 print
'<td>' . $langs->trans(
"Description") .
'</td>';
403 print
'<td class="center">' . $langs->trans(
"DateCreation") .
'</td>';
404 print
'<td class="center">' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
405 print
'<td class="center">' . $langs->trans(
"QtyPreparedOrShipped") .
'</td>';
407 print
'<td>' . $langs->trans(
"Warehouse") .
'</td>';
416 print
'<td>' . $langs->trans(
"DeliveryOrder") .
'</td>';
418 print
'<td class="right">' . $langs->trans(
"DeliveryDate") .
'</td>';
423 $objp = $db->fetch_object($resql);
425 $expedition->id = $objp->expedition_id;
426 $expedition->ref = $objp->exp_ref;
427 $expedition->billed = $objp->billed;
428 $expedition->statut = $objp->status;
429 $expedition->status = $objp->status;
430 $expedition->signed_status = $objp->signed_status;
432 print
'<tr class="oddeven">';
435 print
'<td class="tdoverflowmax125">';
436 print $expedition->getNomUrl(1);
441 if ($objp->fk_product > 0) {
445 '@phan-var-force CommonObject $object';
450 $prod->id = $objp->fk_product;
451 $prod->getMultiLangs();
453 $outputlangs = $langs;
455 if (
GETPOST(
'lang_id',
'aZ09')) {
456 $newlang =
GETPOST(
'lang_id',
'aZ09');
458 if (empty($newlang)) {
459 $newlang =
$object->thirdparty->default_lang;
461 if (!empty($newlang)) {
463 $outputlangs->setDefaultLang($newlang);
466 $label = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"label"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"label"] : $objp->product_label;
468 $label = (!empty($objp->label) ? $objp->label : $objp->product_label);
474 $product_static->type = $objp->fk_product_type;
475 $product_static->id = $objp->fk_product;
476 $product_static->ref = $objp->ref;
477 $product_static->status_batch = $objp->product_tobatch;
479 $text = $product_static->getNomUrl(1);
480 $text .=
' - ' . $label;
482 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
489 print(!empty($objp->description) ? ((empty($objp->product) || $objp->description != $objp->product) ?
'<br>' .
dol_htmlentitiesbr($objp->description) :
'') :
'');
495 if ($objp->fk_product_type == 1) {
496 $text = img_object($langs->trans(
'Service'),
'service');
498 $text = img_object($langs->trans(
'Product'),
'product');
501 if (!empty($objp->label)) {
502 $text .=
' <strong>' . $objp->label .
'</strong>';
503 print $form->textwithtooltip($text, $objp->description, 3, 0,
'', (
string) $i);
505 print $text .
' ' . nl2br($objp->description);
516 print
'<td class="nowrap center">' .
dol_print_date($db->jdate($objp->date_creation),
'day') .
'</td>';
519 print
'<td class="nowrap center">' .
dol_print_date($db->jdate($objp->date_delivery),
'day') .
'</td>';
522 print
'<td class="center">' . $objp->qty_shipped .
'</td>';
526 print
'<td class="tdoverflowmax125">';
527 if ($objp->warehouse_id > 0) {
528 $warehousestatic->fetch($objp->warehouse_id);
529 print $warehousestatic->getNomUrl(1);
568 include_once DOL_DOCUMENT_ROOT .
'/delivery/class/delivery.class.php';
569 $expedition->fetchObjectLinked($expedition->id, $expedition->element,
null,
'delivery');
573 if (!empty($expedition->linkedObjects[
'delivery'])) {
574 $receiving = reset($expedition->linkedObjects[
'delivery']);
577 if (!empty($receiving)) {
579 '@phan-var-force Delivery $receiving';
587 print $receiving->getNomUrl(1);
597 print
'<td class="right">';
602 print
'<td> </td>';
603 print
'<td> </td>';
615 dol_print_error($db);
if(! $sortfield) if(! $sortorder) $object
Class to manage customers orders.
Class to manage warehouses.
const STATUS_DRAFT
Draft status.
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage products or services.
Class to manage translations.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_setcache($memoryid, $data, $expire=0, $filecache=0, $replace=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
delivery_prepare_head($object)
Prepare array with list of tabs.
shipping_prepare_head($object)
Prepare array with list of tabs.
shippingGetStandaloneDispatchSourceLine($object, $sourceLineId, $lineId, $productId)
Resolve a standalone dispatch group from the loaded shipment lines.