24 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
25 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
37 global $db, $langs, $conf, $user;
40 $langs->loadLangs(array(
"sendings",
"deliveries"));
45 $head[$h][0] = DOL_URL_ROOT.
"/expedition/card.php?id=".$object->id;
46 $head[$h][1] = $langs->trans(
"SendingCard");
47 $head[$h][2] =
'shipping';
50 if ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire) {
52 $object->fetchObjectLinked($object->id, $object->element);
53 if (is_array($object->linkedObjectsIds[
'delivery']) && count($object->linkedObjectsIds[
'delivery']) > 0) {
55 $tmp = reset($object->linkedObjectsIds[
'delivery']);
57 $head[$h][0] = DOL_URL_ROOT.
"/delivery/card.php?id=".$tmp;
58 $head[$h][1] = $langs->trans(
"DeliveryCard");
59 $head[$h][2] =
'delivery';
64 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
66 if ($object->origin ==
'commande' && $object->origin_id > 0) {
68 $objectsrc->fetch($object->origin_id);
70 $nbContact = count($objectsrc->liste_contact(-1,
'internal')) + count($objectsrc->liste_contact(-1,
'external'));
71 $head[$h][0] = DOL_URL_ROOT.
"/expedition/contact.php?id=".$object->id;
72 $head[$h][1] = $langs->trans(
"ContactsAddresses");
74 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
76 $head[$h][2] =
'contact';
80 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
81 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
83 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
84 $nbLinks =
Link::count($db, $object->element, $object->id);
85 $head[$h][0] = DOL_URL_ROOT.
'/expedition/document.php?id='.$object->id;
86 $head[$h][1] = $langs->trans(
'Documents');
87 if (($nbFiles + $nbLinks) > 0) {
88 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
90 $head[$h][2] =
'documents';
94 if (!empty($object->note_private)) {
97 if (!empty($object->note_public)) {
100 $head[$h][0] = DOL_URL_ROOT.
"/expedition/note.php?id=".$object->id;
101 $head[$h][1] = $langs->trans(
"Notes");
103 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
105 $head[$h][2] =
'note';
128 global $langs, $db, $conf, $user;
131 $langs->loadLangs(array(
"sendings",
"deliveries"));
136 if ($conf->expedition_bon->enabled && $user->rights->expedition->lire) {
137 $head[$h][0] = DOL_URL_ROOT.
"/expedition/card.php?id=".$object->origin_id;
138 $head[$h][1] = $langs->trans(
"SendingCard");
139 $head[$h][2] =
'shipping';
143 $head[$h][0] = DOL_URL_ROOT.
"/delivery/card.php?id=".$object->id;
144 $head[$h][1] = $langs->trans(
"DeliveryCard");
145 $head[$h][2] =
'delivery';
154 $savObjectId = $object->id;
158 if ($object->origin) {
160 $tmpobject->fetch($object->origin_id);
162 $tmpobject = $object;
165 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
166 $objectsrc = $tmpobject;
167 if ($tmpobject->origin ==
'commande' && $tmpobject->origin_id > 0) {
169 $objectsrc->fetch($tmpobject->origin_id);
171 $nbContact = count($objectsrc->liste_contact(-1,
'internal')) + count($objectsrc->liste_contact(-1,
'external'));
172 $head[$h][0] = DOL_URL_ROOT.
"/expedition/contact.php?id=".$tmpobject->id;
173 $head[$h][1] = $langs->trans(
"ContactsAddresses");
174 if ($nbContact > 0) {
175 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
177 $head[$h][2] =
'contact';
181 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
182 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
184 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
185 $nbLinks =
Link::count($db, $tmpobject->element, $tmpobject->id);
186 $head[$h][0] = DOL_URL_ROOT.
'/expedition/document.php?id='.$tmpobject->id;
187 $head[$h][1] = $langs->trans(
'Documents');
188 if (($nbFiles + $nbLinks) > 0) {
189 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
191 $head[$h][2] =
'documents';
195 if (!empty($tmpobject->note_private)) {
198 if (!empty($tmpobject->note_public)) {
201 $head[$h][0] = DOL_URL_ROOT.
"/expedition/note.php?id=".$tmpobject->id;
202 $head[$h][1] = $langs->trans(
"Notes");
204 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
206 $head[$h][2] =
'note';
209 $object->id = $tmpobject->id;
215 $object->id = $savObjectId;
229 global $db, $conf, $langs;
232 $product_static =
new Product($db);
234 $warehousestatic =
new Entrepot($db);
236 $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,";
237 $sql .=
" ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,";
238 $sql .=
" e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
240 $sql .=
' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,';
241 $sql .=
' p.description as product_desc';
242 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed";
243 $sql .=
", ".MAIN_DB_PREFIX.
"expedition as e";
244 $sql .=
", ".MAIN_DB_PREFIX.$origin.
"det as obj";
246 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON obj.fk_product = p.rowid";
248 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
249 $sql .=
" AND obj.fk_".$origin.
" = ".((int) $origin_id);
250 $sql .=
" AND obj.rowid = ed.fk_origin_line";
251 $sql .=
" AND ed.fk_expedition = e.rowid";
256 $sql .=
" ORDER BY obj.fk_product";
258 dol_syslog(
"show_list_sending_receive", LOG_DEBUG);
259 $resql = $db->query($sql);
261 $num = $db->num_rows(
$resql);
271 print
'<table class="liste centpercent">';
272 print
'<tr class="liste_titre">';
274 print
'<td>'.$langs->trans(
"SendingSheet").
'</td>';
275 print
'<td>'.$langs->trans(
"Description").
'</td>';
276 print
'<td class="center">'.$langs->trans(
"DateCreation").
'</td>';
277 print
'<td class="center">'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
278 print
'<td class="center">'.$langs->trans(
"QtyPreparedOrShipped").
'</td>';
279 if (!empty($conf->stock->enabled)) {
280 print
'<td>'.$langs->trans(
"Warehouse").
'</td>';
288 if (!empty($conf->delivery_note->enabled)) {
289 print
'<td>'.$langs->trans(
"DeliveryOrder").
'</td>';
291 print
'<td class="right">'.$langs->trans(
"DeliveryDate").
'</td>';
296 $objp = $db->fetch_object(
$resql);
298 print
'<tr class="oddeven">';
301 print
'<td class="nowrap left">';
302 print
'<a href="'.DOL_URL_ROOT.
'/expedition/card.php?id='.$objp->expedition_id.
'">'.
img_object($langs->trans(
"ShowSending"),
'sending').
' '.$objp->exp_ref.
'<a>';
306 if ($objp->fk_product > 0) {
308 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
309 $object =
new $origin($db);
310 $object->fetch($origin_id);
311 $object->fetch_thirdparty();
314 $prod->id = $objp->fk_product;
315 $prod->getMultiLangs();
317 $outputlangs = $langs;
319 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
320 $newlang =
GETPOST(
'lang_id',
'aZ09');
322 if (empty($newlang)) {
323 $newlang = $object->thirdparty->default_lang;
325 if (!empty($newlang)) {
327 $outputlangs->setDefaultLang($newlang);
330 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $objp->product_label;
332 $label = (!empty($objp->label) ? $objp->label : $objp->product_label);
338 $product_static->type = $objp->fk_product_type;
339 $product_static->id = $objp->fk_product;
340 $product_static->ref = $objp->ref;
341 $product_static->status_batch = $objp->product_tobatch;
342 $text = $product_static->getNomUrl(1);
343 $text .=
' - '.$label;
344 $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ?
'' :
dol_htmlentitiesbr($objp->description));
345 print
$form->textwithtooltip($text, $description, 3,
'',
'', $i);
351 if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
352 print (!empty($objp->description) && $objp->description != $objp->product) ?
'<br>'.dol_htmlentitiesbr($objp->description) :
'';
358 if ($objp->fk_product_type == 1) {
359 $text =
img_object($langs->trans(
'Service'),
'service');
361 $text =
img_object($langs->trans(
'Product'),
'product');
364 if (!empty($objp->label)) {
365 $text .=
' <strong>'.$objp->label.
'</strong>';
366 print
$form->textwithtooltip($text, $objp->description, 3,
'',
'', $i);
368 print $text.
' '.nl2br($objp->description);
379 print
'<td class="nowrap center">'.dol_print_date($db->jdate($objp->date_creation),
'day').
'</td>';
382 print
'<td class="nowrap center">'.dol_print_date($db->jdate($objp->date_delivery),
'day').
'</td>';
385 print
'<td class="center">'.$objp->qty_shipped.
'</td>';
388 if (!empty($conf->stock->enabled)) {
390 if ($objp->warehouse_id > 0) {
391 $warehousestatic->fetch($objp->warehouse_id);
392 print $warehousestatic->getNomUrl(1);
430 if (!empty($conf->delivery_note->enabled)) {
431 include_once DOL_DOCUMENT_ROOT.
'/delivery/class/delivery.class.php';
432 $expedition->id = $objp->sendingid;
433 $expedition->fetchObjectLinked($expedition->id, $expedition->element);
437 if (!empty($expedition->linkedObjects[
'delivery'])) {
438 $receiving = reset($expedition->linkedObjects[
'delivery']);
441 if (!empty($receiving)) {
449 print $receiving->getNomUrl($db);
459 print
'<td class="right">';
464 print
'<td> </td>';
465 print
'<td> </td>';