From 148645d220fc6e1edd4c343e2d879b7e6f2c4923 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Mar 2023 12:10:48 +0200 Subject: [PATCH 1/6] Fix error 500 on payment --- htdocs/public/payment/paymentko.php | 4 +++- htdocs/public/payment/paymentok.php | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 4174267a769..05dc401d158 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -131,7 +131,9 @@ dol_syslog("Callback url when an online payment is refused or canceled. query_st $tracepost = ""; foreach ($_POST as $k => $v) { - $tracepost .= "{$k} - {$v}\n"; + if (is_scalar($k) && is_scalar($v)) { + $tracepost .= "{$k} - {$v}\n"; + } } dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index e596fd3d261..e19fd856f23 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -173,12 +173,16 @@ dol_syslog("_SERVER[SERVER_ADDR] = ".(empty($_SERVER["SERVER_ADDR"]) ? '' : dol_ $tracepost = ""; foreach ($_POST as $k => $v) { - $tracepost .= "{$k} - {$v}\n"; + if (is_scalar($k) && is_scalar($v)) { + $tracepost .= "{$k} - {$v}\n"; + } } dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); $tracesession = ""; foreach ($_SESSION as $k => $v) { - $tracesession .= "{$k} - {$v}\n"; + if (is_scalar($k) && is_scalar($v)) { + $tracesession .= "{$k} - {$v}\n"; + } } dol_syslog("SESSION=".$tracesession, LOG_DEBUG, 0, '_payment'); From e9d92531478c998448feca24c56510327b4c17eb Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 31 Mar 2023 12:36:43 +0200 Subject: [PATCH 2/6] fix : Warning: Undefined array key align in /home/httpd/vhosts/aflac.fr/domains/dev.aflac.fr/httpdocs/core/class/commondocgenerator.class.php on line 1575 --- htdocs/core/class/commondocgenerator.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1b59d44bdde..2278a1de8dc 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1567,17 +1567,21 @@ abstract class CommonDocGenerator // set cell padding with column title definition $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], $colDef['title']['padding'][2]); } - + if (isset($colDef['title']['align'])) { + $align = $colDef['title']['align']; + } else { + $align = ''; + } $pdf->SetXY($colDef['xStartPos'], $tab_top); $textWidth = $colDef['width']; - $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); + $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $align); // Add variant of translation if $outputlangsbis is an object if (is_object($outputlangsbis) && trim($colDef['title']['label'])) { $pdf->setCellPaddings($colDef['title']['padding'][3], 0, $colDef['title']['padding'][1], $colDef['title']['padding'][2]); $pdf->SetXY($colDef['xStartPos'], $pdf->GetY()); $textbis = $outputlangsbis->transnoentities($colDef['title']['textkey']); - $pdf->MultiCell($textWidth, 2, $textbis, '', $colDef['title']['align']); + $pdf->MultiCell($textWidth, 2, $textbis, '', $align); } $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight); From a823b10b58682623147d3f1e3dffec358de61b86 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Mar 2023 12:41:52 +0200 Subject: [PATCH 3/6] Fix load lang --- htdocs/eventorganization/conferenceorboothattendee_list.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 1bc9c12d4f6..fc8db4ff6b3 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -41,11 +41,8 @@ if (isModEnabled('categorie')) { global $dolibarr_main_url_root; -// for other modules -//dol_include_once('/othermodule/class/otherobject.class.php'); - // Load translation files required by the page -$langs->loadLangs(array("eventorganization", "other", "projects")); +$langs->loadLangs(array("eventorganization", "other", "projects", "bills")); // Get Paramters $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... From d388ac58beac00a71a6317f90bb89de7a06f09b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Mar 2023 13:31:23 +0200 Subject: [PATCH 4/6] Fix public pages --- .../public/eventorganization/attendee_new.php | 53 ++++---- htdocs/public/project/index.php | 118 ++++++++++++++++-- htdocs/public/project/suggestbooth.php | 61 ++++++--- htdocs/public/project/suggestconference.php | 68 +++++++--- 4 files changed, 234 insertions(+), 66 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index a345897070c..1b9a555f246 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -680,22 +681,25 @@ $formcompany = new FormCompany($db); llxHeaderVierge($langs->trans("NewRegistration")); -print '
'; -print load_fiche_titre($langs->trans("NewRegistration"), '', '', 0, 0, 'center'); - print '
'; print '
'; -print '
'; +// Sub banner +print '
'; +print load_fiche_titre($langs->trans("NewRegistration"), '', '', 0, 0, 'center'); // Welcome message print ''.$langs->trans("EvntOrgWelcomeMessage").''; print '
'; - // Title -print ''.dol_escape_htmltag($project->title . ' '. $conference->label).'
'; +print ''.dol_escape_htmltag($project->title . ' '. $conference->label).'
'; +print '
'; + +// Help text +print '
'; + if ($project->date_start_event || $project->date_end_event) { - print '
'; + print '
'; } if ($project->date_start_event) { $format = 'day'; @@ -720,29 +724,31 @@ if ($project->date_start_event || $project->date_end_event) { print '
'; } if ($project->location) { - print ''.dol_escape_htmltag($project->location).'
'; + print ''.dol_escape_htmltag($project->location).'
'; } +print '
'; + + $maxattendees = 0; if ($conference->id > 0) { /* date of project is not date of event so commented - print $langs->trans("Date").': '; - print dol_print_date($conference->datep); - if ($conference->date_end) { - print ' - '; - print dol_print_date($conference->datef); - }*/ + print $langs->trans("Date").': '; + print dol_print_date($conference->datep); + if ($conference->date_end) { + print ' - '; + print dol_print_date($conference->datef); + }*/ } else { /* date of project is not date of event so commented - print $langs->trans("Date").': '; - print dol_print_date($project->date_start); - if ($project->date_end) { - print ' - '; - print dol_print_date($project->date_end); - }*/ + print $langs->trans("Date").': '; + print dol_print_date($project->date_start); + if ($project->date_end) { + print ' - '; + print dol_print_date($project->date_end); + }*/ $maxattendees = $project->max_attendees; // Max attendeed for the project/event } -print '
'; if ($maxattendees && $currentnbofattendees >= $maxattendees) { print '
'; @@ -884,12 +890,15 @@ if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS print "\n"; print "
"; - print '
'; } } else { + print '

'; print $langs->trans("ConferenceIsNotConfirmed"); + print '

'; } +print ''; + llxFooterVierge(); $db->close(); diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index dfcfde94b17..3488fe8e4c4 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -124,10 +124,14 @@ $conf->dol_hide_topmenu = 1; $conf->dol_hide_leftmenu = 1; $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; -llxHeader($head, $langs->trans("SuggestForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); + + +llxHeaderVierge($langs->trans("SuggestForm")); + print ''."\n"; print '
'."\n"; + print '
'."\n"; print ''."\n"; print ''."\n"; @@ -150,7 +154,7 @@ if (!empty($conf->global->$paramlogo)) { } elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) { $logosmall = $conf->global->ONLINE_PAYMENT_LOGO; } -//print ''."\n"; +//print '- Show logo (logosmall='.$logosmall.' logo='.$logo.') '."\n"; // Define urllogo $urllogo = ''; $urllogofull = ''; @@ -184,21 +188,55 @@ if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) { print '
'; +print '
'; +print '
'; + + // Event summary print '
'; -print ''.$project->title.'
'; -print img_picto('', 'calendar', 'class="pictofixedwidth"').$langs->trans("Date").': '; -print dol_print_date($project->date_start, 'daytext'); -if ($project->date_end && $project->date_start != $project->date_end) { - print ' - '.dol_print_date($project->date_end, 'daytext'); -} +print ''.dol_escape_htmltag($project->title . ' '. $project->label).'
'; print '

'."\n"; -print $langs->trans("EvntOrgRegistrationWelcomeMessage")."\n"; +print ''.$langs->trans("EvntOrgRegistrationWelcomeMessage")."\n"; print $project->note_public."\n"; //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx'; print '
'; +// Help text +print '
'; + +if ($project->date_start_event || $project->date_end_event) { + print '
'; +} +if ($project->date_start_event) { + $format = 'day'; + $tmparray = dol_getdate($project->date_start_event, false, ''); + if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) { + $format = 'dayhour'; + } + print dol_print_date($project->date_start_event, $format); +} +if ($project->date_start_event && $project->date_end_event) { + print ' - '; +} +if ($project->date_end_event) { + $format = 'day'; + $tmparray = dol_getdate($project->date_end_event, false, ''); + if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) { + $format = 'dayhour'; + } + print dol_print_date($project->date_end_event, $format); +} +if ($project->date_start_event || $project->date_end_event) { + print '
'; +} +if ($project->location) { + print ''.dol_escape_htmltag($project->location).'
'; +} + +print '
'; + + print '
'; print ''."\n"; @@ -245,6 +283,10 @@ print ''."\n"; print '
'."\n"; + +print '
'; + + print '
'."\n"; print '
'."\n"; print '
'; @@ -255,3 +297,61 @@ htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object); llxFooter('', 'public'); $db->close(); + + + +/** + * Show header for new member + * + * @param string $title Title + * @param string $head Head array + * @param int $disablejs More content into html header + * @param int $disablehead More content into html header + * @param array $arrayofjs Array of complementary js files + * @param array $arrayofcss Array of complementary css files + * @return void + */ +function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '') +{ + global $user, $conf, $langs, $mysoc; + + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers + + print ''; + + // Define urllogo + $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; + + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); + } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) { + $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg'; + } + + print '
'; + + // Output html code for logo + if ($urllogo) { + print '
'; + print '
'; + print ''; + print '
'; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print '
'; + } + + if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_CONFERENCE)) { + print '
'; + print ''; + print '
'; + } + + print '
'; + + print '
'; +} diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index 0b2e24716d5..772822374d4 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -477,6 +477,7 @@ if (empty($reshook) && $action == 'add') { } } } + if (!$error) { $db->commit(); @@ -542,30 +543,61 @@ $formcompany = new FormCompany($db); llxHeaderVierge($langs->trans("NewSuggestionOfBooth")); + +print '
'; +print '
'; + print '
'; // Event summary print '
'; -print ''.$project->title.'
'; -print img_picto('', 'calendar', 'class="pictofixedwidth"').$langs->trans("Date").': '; -print dol_print_date($project->date_start, 'daytext'); -if ($project->date_end && $project->date_start != $project->date_end) { - print ' - '.dol_print_date($project->date_end, 'daytext'); -} +print ''.dol_escape_htmltag($project->title . ' '. $project->label).'
'; print '

'."\n"; -//print $langs->trans("EvntOrgRegistrationWelcomeMessage")."\n"; -//print $project->note_public."\n"; +print ''.$langs->trans("EvntOrgRegistrationWelcomeMessage")."\n"; +print $project->note_public."\n"; //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx'; print '
'; +// Help text +print '
'; + +if ($project->date_start_event || $project->date_end_event) { + print '
'; +} +if ($project->date_start_event) { + $format = 'day'; + $tmparray = dol_getdate($project->date_start_event, false, ''); + if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) { + $format = 'dayhour'; + } + print dol_print_date($project->date_start_event, $format); +} +if ($project->date_start_event && $project->date_end_event) { + print ' - '; +} +if ($project->date_end_event) { + $format = 'day'; + $tmparray = dol_getdate($project->date_end_event, false, ''); + if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) { + $format = 'dayhour'; + } + print dol_print_date($project->date_end_event, $format); +} +if ($project->date_start_event || $project->date_end_event) { + print '
'; +} +if ($project->location) { + print ''.dol_escape_htmltag($project->location).'
'; +} + +print '
'; + +print '
'; + print load_fiche_titre($langs->trans("NewSuggestionOfBooth"), '', '', 0, 0, 'center'); -print '
'; -print '
'; -print '
'; - dol_htmloutput_errors($errmsg); // Print form @@ -576,7 +608,6 @@ print ''; print ''; print ''; -print '
'; print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; //print $langs->trans("FieldsWithIsForPublic",'**').'
'; @@ -616,8 +647,7 @@ print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'se print ''; // Country print ''.$langs->trans('Country'); -print '*'; - +print '*'; print ''; $country_id = GETPOST('country_id'); if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { @@ -670,7 +700,6 @@ print '
'; print '

'; - print "\n"; print "
"; print '
'; diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index b3418ec9e84..77196c8c6fa 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -72,8 +72,8 @@ $email = GETPOST("email"); $societe = GETPOST("societe"); $label = GETPOST("label"); $note = GETPOST("note"); -$datestart = GETPOST("datestart"); -$dateend = GETPOST("dateend"); +$datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int')); +$dateend = dol_mktime(23, 59, 59, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int')); $id = GETPOST('id'); @@ -454,6 +454,7 @@ if (empty($reshook) && $action == 'add') { } } } + if (!$error) { $db->commit(); $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); @@ -475,29 +476,60 @@ $formcompany = new FormCompany($db); llxHeaderVierge($langs->trans("NewSuggestionOfConference")); + +print '
'; +print '
'; + print '
'; // Event summary print '
'; -print ''.$project->title.'
'; -print img_picto('', 'calendar', 'class="pictofixedwidth"').$langs->trans("Date").': '; -print dol_print_date($project->date_start, 'daytext'); -if ($project->date_end && $project->date_start != $project->date_end) { - print ' - '.dol_print_date($project->date_end, 'daytext'); -} +print ''.dol_escape_htmltag($project->title . ' '. $project->label).'
'; print '

'."\n"; -//print $langs->trans("EvntOrgRegistrationWelcomeMessage")."\n"; -//print $project->note_public."\n"; +print ''.$langs->trans("EvntOrgRegistrationWelcomeMessage")."\n"; +print $project->note_public."\n"; //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx'; print '
'; +// Help text +print '
'; + +if ($project->date_start_event || $project->date_end_event) { + print '
'; +} +if ($project->date_start_event) { + $format = 'day'; + $tmparray = dol_getdate($project->date_start_event, false, ''); + if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) { + $format = 'dayhour'; + } + print dol_print_date($project->date_start_event, $format); +} +if ($project->date_start_event && $project->date_end_event) { + print ' - '; +} +if ($project->date_end_event) { + $format = 'day'; + $tmparray = dol_getdate($project->date_end_event, false, ''); + if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) { + $format = 'dayhour'; + } + print dol_print_date($project->date_end_event, $format); +} +if ($project->date_start_event || $project->date_end_event) { + print '
'; +} +if ($project->location) { + print ''.dol_escape_htmltag($project->location).'
'; +} + +print '
'; + +print '
'; print load_fiche_titre($langs->trans("NewSuggestionOfConference"), '', '', 0, 0, 'center'); -print '
'; -print '
'; -print '
'; dol_htmloutput_errors($errmsg, $errors); @@ -509,8 +541,6 @@ print ''; print ''; print ''; -print '
'; - print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; //print $langs->trans("FieldsWithIsForPublic",'**').'
'; @@ -585,11 +615,11 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''.$langs->trans("Format").'*'."\n"; print ''.Form::selectarray('eventtype', $arrayofconfboothtype, $eventtype, 1).''; // Label -print ''.$langs->trans("LabelOfconference").'*'."\n"; -print ''."\n"; +print ''.$langs->trans("LabelOfconference").'*'."\n"; +print ''."\n"; // Note -print ''.$langs->trans("Description").'*'."\n"; -print ''."\n"; +print ''.$langs->trans("Description").'*'."\n"; +print ''."\n"; print "\n"; From 96d23fac5f9fa8fa307e8c8cc50af3115a9257fa Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 31 Mar 2023 16:57:03 +0200 Subject: [PATCH 5/6] FIX: project referent elements list: conf to hide tasks was flipped --- htdocs/projet/element.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 935275bfe54..1bdefbcc1e6 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -580,7 +580,7 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'buttonnew'=>'AddTimeSpent', 'testnew'=>$user->hasRight('project', 'creer'), - 'test'=>!empty($conf->project->enabled) && $user->hasRight('projet', 'lire') && !empty($conf->global->PROJECT_HIDE_TASKS)), + 'test'=>!empty($conf->project->enabled) && $user->hasRight('projet', 'lire') && empty($conf->global->PROJECT_HIDE_TASKS)), 'stock_mouvement'=>array( 'name'=>"MouvementStockAssociated", 'title'=>"ListMouvementStockProject", From 6c589955a679506792676256fe992dff30c0054a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 1 Apr 2023 15:00:54 +0200 Subject: [PATCH 6/6] FIX Autofill / clear qty in inventory page --- htdocs/product/inventory/inventory.php | 1516 ++++++++++++------------ 1 file changed, 761 insertions(+), 755 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 506b6e0c198..5f72928ed13 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -428,772 +428,779 @@ $help_url = ''; llxHeader('', $langs->trans('Inventory'), $help_url); // Part to show record -if ($object->id > 0) { - $res = $object->fetch_optionals(); - - $head = inventoryPrepareHead($object); - print dol_get_fiche_head($head, 'inventory', $langs->trans("Inventory"), -1, 'stock'); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid.'&page='.$page.$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); - } - - // Clone confirmation - if ($action == 'clone') { - // Create an array for form - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } - - // Confirmation to close - if ($action == 'record') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $langs->trans('ConfirmFinish'), 'update', '', 0, 1); - $action = 'view'; - } - - // Confirmation to close - if ($action == 'confirm_cancel') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $langs->trans('ConfirmCancel'), 'cancel_record', '', 0, 1); - $action = 'view'; - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; +if ($object->id <= 0) { + dol_print_error('', 'Bad value for object id'); + exit; +} - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; +$res = $object->fetch_optionals(); - $morehtmlref = '
'; - /* - // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->inventory->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->inventory->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (!empty($conf->project->enabled)) +$head = inventoryPrepareHead($object); +print dol_get_fiche_head($head, 'inventory', $langs->trans("Inventory"), -1, 'stock'); + +$formconfirm = ''; + +// Confirmation to delete +if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); +} +// Confirmation to delete line +if ($action == 'deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid.'&page='.$page.$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); +} + +// Clone confirmation +if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); +} + +// Confirmation to close +if ($action == 'record') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $langs->trans('ConfirmFinish'), 'update', '', 0, 1); + $action = 'view'; +} + +// Confirmation to close +if ($action == 'confirm_cancel') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $langs->trans('ConfirmCancel'), 'cancel_record', '', 0, 1); + $action = 'view'; +} + +// Call Hook formConfirm +$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); +$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; +} elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; +} + +// Print form confirm +print $formconfirm; + + +// Object card +// ------------------------------------------------------------ +$linkback = ''.$langs->trans("BackToList").''; + +$morehtmlref = '
'; +/* +// Ref bis +$morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->inventory->creer, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->inventory->creer, 'string', '', null, null, '', 1); +// Thirdparty +$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); +// Project +if (!empty($conf->project->enabled)) +{ + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->inventory->creer) { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->inventory->creer) + if ($action != 'classify') { - if ($action != 'classify') - { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(); - } else { - $morehtmlref.=''; - } + $morehtmlref.=''; } } - */ - $morehtmlref .= '
'; +} +*/ +$morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); +dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; - print ''."\n"; +print '
'; +print '
'; +print '
'; +print '
'."\n"; - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; +// Common attributes +include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - // Other attributes. Fields from hook formObjectOptions and Extrafields. - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; +// Other attributes. Fields from hook formObjectOptions and Extrafields. +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - //print ''; +//print ''; - print '
'.$langs->trans("InventoryCode").'INV'.$object->id.'
'.$langs->trans("InventoryCode").'INV'.$object->id.'
'; - print '
'; - print '
'; +print ''; +print '
'; +print '
'; - print '
'; +print '
'; - print dol_get_fiche_end(); +print dol_get_fiche_end(); - print '
'; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; +print ''; +print ''; +print ''; +print ''; +if ($backtopage) { + print ''; +} + + +// Buttons for actions +if ($action != 'record') { + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - - // Buttons for actions - if ($action != 'record') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook)) { - if ($object->status == Inventory::STATUS_DRAFT) { - if ($permissiontoadd) { - print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'."\n"; - } else { - print ''.$langs->trans('Validate').' ('.$langs->trans("Start").')'."\n"; - } - } - - // Save - if ($object->status == $object::STATUS_VALIDATED) { - if ($permissiontoadd) { - print ''.$langs->trans("MakeMovementsAndClose").''."\n"; - } else { - print ''.$langs->trans('MakeMovementsAndClose').''."\n"; - } - - if ($permissiontoadd) { - print ''.$langs->trans("Cancel").''."\n"; - } - } - } - print '
'."\n"; - - if ($object->status != Inventory::STATUS_DRAFT && $object->status != Inventory::STATUS_VALIDATED) { - print '

'; - } - } - - - - if ($object->status == Inventory::STATUS_VALIDATED) { - print '
'; - if (!empty($conf->use_javascript_ajax)) { + if (empty($reshook)) { + if ($object->status == Inventory::STATUS_DRAFT) { if ($permissiontoadd) { - // Link to launch scan tool - if (isModEnabled('barcode') || isModEnabled('productbatch')) { - print ''.img_picto('', 'barcode', 'class="paddingrightonly"').$langs->trans("UpdateByScaning").''; - } - - // Link to autofill - print ''.img_picto('', 'autofill', 'class="paddingrightonly"').$langs->trans('AutofillWithExpected').''; - print ''; - - // Link to reset qty - print ''.img_picto('', 'eraser', 'class="paddingrightonly"').$langs->trans("ClearQtys").''; + print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'."\n"; } else { - print ''.$langs->trans("Save").''."\n"; + print ''.$langs->trans('Validate').' ('.$langs->trans("Start").')'."\n"; } } - print '
'; - print '
'; - print '
'; - } - - - // Popup for mass barcode scanning - if ($action == 'updatebyscaning') { - if ($permissiontoadd) { - // Output the javascript to manage the scanner tool. - print ''; + + // Link to reset qty + print ''.img_picto('', 'eraser', 'class="paddingrightonly"').$langs->trans("ClearQtys").''; + } else { + print ''.$langs->trans("Save").''."\n"; + } + } + print '
'; + print '
'; + print ''; +} + + +// Popup for mass barcode scanning +if ($action == 'updatebyscaning') { + if ($permissiontoadd) { + // Output the javascript to manage the scanner tool. + print ''; + if(BarcodeIsInProduct > 0){ + result = true; + } + return result; } - include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother = new FormOther($db); - print $formother->getHTMLScannerForm("barcodescannerjs", 'all'); + '; + print ''; } + include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($db); + print $formother->getHTMLScannerForm("barcodescannerjs", 'all'); +} - //Call method to undo changes in real qty - print ''; +//Call method to undo changes in real qty +print ''; - print '
'; - //print '
'; - print '
'; +print '
'; +//print '
'; +print '
'; - //print load_fiche_titre($langs->trans('Consumption'), '', ''); +//print load_fiche_titre($langs->trans('Consumption'), '', ''); - print '
'; - print ''; +print '
'; +print '
'; - print ''; - print ''; - print ''; +print ''; +print ''; +print ''; +if (isModEnabled('productbatch')) { + print ''; +} +print ''; +if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + print ''; + print ''; + print ''; + print ''; + print ''; +} else { + print ''; +} +if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { + // Actions or link to stock movement + print ''; +} else { + // Actions or link to stock movement + print ''; +} +print ''; + +// Line to add a new line in inventory +if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { + print ''; + print ''; + print ''; if (isModEnabled('productbatch')) { print ''; } - print ''; + print ''; if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } else { print ''; - } - if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - // Actions or link to stock movement - print ''; - } else { - // Actions or link to stock movement - print ''; } + // Actions + print ''; print ''; +} - // Line to add a new line in inventory - if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - print ''; - print ''; + print ''; - print ''; + if (isModEnabled('productbatch')) { - print ''; } - print ''; - if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { - print ''; - print ''; - print ''; - print ''; + + // Expected quantity = Quantity in stock when we start inventory + print ''; + + // Real quantity + if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { + $qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view; + + //if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) { + if ($qty_view != '') { + $hasinput = true; + } + + if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + //PMP Expected + if (!empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; + else $pmp_expected = $product_static->pmp; + $pmp_valuation = $pmp_expected * $valuetoshow; + print ''; + print ''; + + print ''; + + //PMP Real + print ''; + print ''; + + $totalExpectedValuation += $pmp_valuation; + $totalRealValuation += $pmp_valuation_real; + } else { + print ''; + } + + // Picto delete line print ''; } else { - print ''; - } - // Actions - print ''; - print ''; - } - - // Request to show lines of inventory (prefilled after start/validate step) - $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; - $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); - $sql .= $db->order('id.rowid', 'ASC'); - $sql .= $db->plimit($limit, $offset); - - $cacheOfProducts = array(); - $cacheOfWarehouses = array(); - - //$sql = ''; - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - if (!empty($limit != 0) || $num > $limit || $page) { - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num >= $limit), '', '', $limit); - } - - $i = 0; - $hasinput = false; - $totalarray = array(); - while ($i < $num) { - $obj = $db->fetch_object($resql); - - if (isset($cacheOfWarehouses[$obj->fk_warehouse])) { - $warehouse_static = $cacheOfWarehouses[$obj->fk_warehouse]; - } else { - $warehouse_static = new Entrepot($db); - $warehouse_static->fetch($obj->fk_warehouse); - - $cacheOfWarehouses[$warehouse_static->id] = $warehouse_static; - } - - // Load real stock we have now - $option = ''; - if (isset($cacheOfProducts[$obj->fk_product])) { - $product_static = $cacheOfProducts[$obj->fk_product]; - } else { - $product_static = new Product($db); - $result = $product_static->fetch($obj->fk_product, '', '', '', 1, 1, 1); - - //$option = 'nobatch'; - $option .= ',novirtual'; - $product_static->load_stock($option); // Load stock_reel + stock_warehouse. - - $cacheOfProducts[$product_static->id] = $product_static; - } - - print ''; - print ''; - print ''; - - if (isModEnabled('productbatch')) { - print ''; - } - - // Expected quantity = Quantity in stock when we start inventory - print ''; - - // Real quantity - if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - $qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view; - - //if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) { - if ($qty_view != '') { - $hasinput = true; - } - - if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { - //PMP Expected - if (!empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; - else $pmp_expected = $product_static->pmp; - $pmp_valuation = $pmp_expected * $valuetoshow; - print ''; - print ''; - - print ''; - - //PMP Real - print ''; - print ''; - - $totalExpectedValuation += $pmp_valuation; - $totalRealValuation += $pmp_valuation_real; - } else { - print ''; - } - - // Picto delete line + if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + //PMP Expected + if (!empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; + else $pmp_expected = $product_static->pmp; + $pmp_valuation = $pmp_expected * $valuetoshow; print ''; + print ''; + + print ''; + + //PMP Real + print ''; + print ''; + print ''; - print ''; - - print ''; - - //PMP Real - print ''; - print ''; - print ''; - } - if ($obj->fk_movement > 0) { - $stockmovment = new MouvementStock($db); - $stockmovment->fetch($obj->fk_movement); - print $stockmovment->getNomUrl(1, 'movements'); - } + print ''; } - print ''; - - $i++; + if ($obj->fk_movement > 0) { + $stockmovment = new MouvementStock($db); + $stockmovment->fetch($obj->fk_movement); + print $stockmovment->getNomUrl(1, 'movements'); + } + print ''; } - } else { - dol_print_error($db); - } - if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { - print ''; - print ''; - print ''; - print ''; - print ''; print ''; + + $i++; } - print '
'.$langs->trans("Warehouse").''.$langs->trans("Product").'
'.$langs->trans("Warehouse").''.$langs->trans("Product").''; + print $langs->trans("Batch"); + print ''.$langs->trans("ExpectedQty").''.$langs->trans('PMPExpected').''.$langs->trans('ExpectedValuation').''.$form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")).''.$langs->trans('PMPReal').''.$langs->trans('RealValuation').''; + print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); + print ''; + print ''; + //print $langs->trans("StockMovement"); + print '
'; + print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? GETPOST('fk_warehouse', 'int') : $object->fk_warehouse), 'fk_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'maxwidth300'); + print ''; + print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOST('fk_product', 'int') : $object->fk_product), 'fk_product', '', 0, 0, -1, 2, '', 0, null, 0, '1', 0, 'maxwidth300'); + print ''; - print $langs->trans("Batch"); + print ''; print ''.$langs->trans("ExpectedQty").''.$langs->trans('PMPExpected').''.$langs->trans('ExpectedValuation').''.$form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")).''.$langs->trans('PMPReal').''.$langs->trans('RealValuation').''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); - print ''; - print ''; - //print $langs->trans("StockMovement"); + print ''; print ''; + print ''; + print '
'; - print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? GETPOST('fk_warehouse', 'int') : $object->fk_warehouse), 'fk_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'maxwidth300'); +// Request to show lines of inventory (prefilled after start/validate step) +$sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; +$sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; +$sql .= ' WHERE id.fk_inventory = '.((int) $object->id); +$sql .= $db->order('id.rowid', 'ASC'); +$sql .= $db->plimit($limit, $offset); + +$cacheOfProducts = array(); +$cacheOfWarehouses = array(); + +//$sql = ''; +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + if (!empty($limit != 0) || $num > $limit || $page) { + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num >= $limit), '', '', $limit); + } + + $i = 0; + $hasinput = false; + $totalarray = array(); + while ($i < $num) { + $obj = $db->fetch_object($resql); + + if (isset($cacheOfWarehouses[$obj->fk_warehouse])) { + $warehouse_static = $cacheOfWarehouses[$obj->fk_warehouse]; + } else { + $warehouse_static = new Entrepot($db); + $warehouse_static->fetch($obj->fk_warehouse); + + $cacheOfWarehouses[$warehouse_static->id] = $warehouse_static; + } + + // Load real stock we have now + $option = ''; + if (isset($cacheOfProducts[$obj->fk_product])) { + $product_static = $cacheOfProducts[$obj->fk_product]; + } else { + $product_static = new Product($db); + $result = $product_static->fetch($obj->fk_product, '', '', '', 1, 1, 1); + + //$option = 'nobatch'; + $option .= ',novirtual'; + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. + + $cacheOfProducts[$product_static->id] = $product_static; + } + + print '
'; + print $warehouse_static->getNomUrl(1); print ''; - print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOST('fk_product', 'int') : $object->fk_product), 'fk_product', '', 0, 0, -1, 2, '', 0, null, 0, '1', 0, 'maxwidth300'); + print ''; + print $product_static->getNomUrl(1).' - '.$product_static->label; print ''; - print ''; + print ''; + $batch_static = new Productlot($db); + $res = $batch_static->fetch(0, $product_static->id, $obj->batch); + if ($res) { + print $batch_static->getNomUrl(1); + } else { + print dol_escape_htmltag($obj->batch); + } print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $valuetoshow = $obj->qty_stock; + // For inventory not yet close, we overwrite with the real value in stock now + if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { + if (isModEnabled('productbatch') && $product_static->hasbatch()) { + $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty; + } else { + $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->real; + } + } + print price2num($valuetoshow, 'MS'); + print ''; + print ''; + print price($pmp_expected); + print ''; + print ''; + print price($pmp_valuation); + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + print ''; + print ''; + + + if (!empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; + else $pmp_real = $product_static->pmp; + $pmp_valuation_real = $pmp_real * $qty_view; + print ''; + print ''; + print ''; + print ''; + print ''; + print img_picto('', 'eraser', 'class="opacitymedium"'); + print ''; + print ''; + print ''; + print ''.img_delete().''; + $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; + print ''; print ''; - print ''; - print ''; - print ''; - print '
'; - print $warehouse_static->getNomUrl(1); - print ''; - print $product_static->getNomUrl(1).' - '.$product_static->label; - print ''; - $batch_static = new Productlot($db); - $res = $batch_static->fetch(0, $product_static->id, $obj->batch); - if ($res) { - print $batch_static->getNomUrl(1); - } else { - print dol_escape_htmltag($obj->batch); - } - print ''; - $valuetoshow = $obj->qty_stock; - // For inventory not yet close, we overwrite with the real value in stock now - if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - if (isModEnabled('productbatch') && $product_static->hasbatch()) { - $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty; - } else { - $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->real; - } - } - print price2num($valuetoshow, 'MS'); - print ''; - print ''; - print price($pmp_expected); - print ''; - print ''; - print price($pmp_valuation); - print ''; - print ''; - print img_picto('', 'eraser', 'class="opacitymedium"'); - print ''; - print ''; - print ''; - - - if (!empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; - else $pmp_real = $product_static->pmp; - $pmp_valuation_real = $pmp_real * $qty_view; - print ''; - print ''; - print ''; - print ''; - print ''; - print img_picto('', 'eraser', 'class="opacitymedium"'); - print ''; - print ''; - print ''; - print ''.img_delete().''; - $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; - print ''; + print price($pmp_expected); print ''; + print price($pmp_valuation); + print ''; + print $obj->qty_view; // qty found + print ''; + if (!empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; + else $pmp_real = $product_static->pmp; + $pmp_valuation_real = $pmp_real * $obj->qty_view; + print price($pmp_real); + print ''; + print price($pmp_valuation_real); + print ''; + + $totalExpectedValuation += $pmp_valuation; + $totalRealValuation += $pmp_valuation_real; } else { - if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { - //PMP Expected - if (!empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; - else $pmp_expected = $product_static->pmp; - $pmp_valuation = $pmp_expected * $valuetoshow; - print ''; - print price($pmp_expected); - print ''; - print price($pmp_valuation); - print ''; - print $obj->qty_view; // qty found - print ''; - if (!empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; - else $pmp_real = $product_static->pmp; - $pmp_valuation_real = $pmp_real * $obj->qty_view; - print price($pmp_real); - print ''; - print price($pmp_valuation_real); - print ''; - - $totalExpectedValuation += $pmp_valuation; - $totalRealValuation += $pmp_valuation_real; - } else { - print ''; - print $obj->qty_view; // qty found - print ''; + print $obj->qty_view; // qty found print '
'.$langs->trans("Total").''.price($totalExpectedValuation).''.price($totalRealValuation).'
'; +} else { + dol_print_error($db); +} +if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { + print ''; + print ''.$langs->trans("Total").''; + print ''.price($totalExpectedValuation).''; + print ''.price($totalRealValuation).''; + print ''; + print ''; +} +print ''; - print '
'; +print '
'; - if ($object->status == $object::STATUS_VALIDATED) { - print '
'; - } +if ($object->status == $object::STATUS_VALIDATED) { + print '
'; +} - print '
'; +print '
'; - // Call method to disable the button if no qty entered yet for inventory - - if ($object->status != $object::STATUS_VALIDATED || !$hasinput) { - print ''; - } - print ''; - +// Call method to disable the button if no qty entered yet for inventory +/* +if ($object->status != $object::STATUS_VALIDATED || !$hasinput) { print ''; +} +*/ + +print ''; + +print ''; +'; - if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { - ?> - - global->INVENTORY_MANAGE_REAL_PMP)) { + ?> + +