Debug v18
This commit is contained in:
parent
94477db4a2
commit
e099ca093a
6 changed files with 115 additions and 33 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
|
|
@ -336,6 +336,14 @@ if ($result) {
|
|||
// Fields title search
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
// Action column
|
||||
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
print '<td class="liste_titre maxwidthsearch center">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td class="liste_titre" width="15%">';
|
||||
print $form->selectDate($date_start === '' ? -1 : $date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
|
||||
print $form->selectDate($date_end === '' ? -1 : $date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
|
||||
|
|
@ -370,15 +378,22 @@ if ($result) {
|
|||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
// Action column
|
||||
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
// Action column
|
||||
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
print_liste_field_titre('');
|
||||
}
|
||||
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "e.dateevent", "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Code", $_SERVER["PHP_SELF"], "e.type", "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, '', $sortfield, $sortorder);
|
||||
|
|
@ -390,7 +405,10 @@ if ($result) {
|
|||
if (!empty($arrayfields['e.prefix_session']['checked'])) {
|
||||
print_liste_field_titre("SuffixSessionName", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
print_liste_field_titre('');
|
||||
// Action column
|
||||
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
print_liste_field_titre('');
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
while ($i < min($num, $limit)) {
|
||||
|
|
@ -398,20 +416,29 @@ if ($result) {
|
|||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Action column
|
||||
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
print '<td class="center">';
|
||||
$htmltext = '<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown"));
|
||||
$htmltext .= '<br><b>'.$langs->trans("SuffixSessionName").' (DOLSESSID_...)</b>: '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
|
||||
print $form->textwithpicto('', $htmltext);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Date
|
||||
print '<td class="nowrap left">'.dol_print_date($db->jdate($obj->dateevent), '%Y-%m-%d %H:%M:%S', 'tzuserrel').'</td>';
|
||||
|
||||
// Code
|
||||
print '<td>'.$obj->type.'</td>';
|
||||
print '<td>'.dol_escape_htmltag($obj->type).'</td>';
|
||||
|
||||
// IP
|
||||
print '<td class="nowrap">';
|
||||
print '<td class="nowraponall">';
|
||||
print dol_print_ip($obj->ip);
|
||||
print '</td>';
|
||||
|
||||
// Login
|
||||
print '<td class="nowrap">';
|
||||
if ($obj->fk_user) {
|
||||
print '<td class="tdoverflowmax150">';
|
||||
if ($obj->fk_user > 0) {
|
||||
$userstatic->id = $obj->fk_user;
|
||||
$userstatic->login = $obj->login;
|
||||
$userstatic->admin = $obj->admin;
|
||||
|
|
@ -446,23 +473,25 @@ if ($result) {
|
|||
if (!empty($arrayfields['e.user_agent']['checked'])) {
|
||||
// User agent
|
||||
print '<td>';
|
||||
print $obj->user_agent;
|
||||
print dol_escape_htmltag($obj->user_agent);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['e.prefix_session']['checked'])) {
|
||||
// User agent
|
||||
print '<td>';
|
||||
print $obj->prefix_session;
|
||||
print dol_escape_htmltag($obj->prefix_session);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// More informations
|
||||
print '<td class="right">';
|
||||
$htmltext = '<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown"));
|
||||
$htmltext .= '<br><b>'.$langs->trans("SuffixSessionName").' (DOLSESSID_...)</b>: '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
|
||||
print $form->textwithpicto('', $htmltext);
|
||||
print '</td>';
|
||||
// Action column
|
||||
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
print '<td class="right">';
|
||||
$htmltext = '<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown"));
|
||||
$htmltext .= '<br><b>'.$langs->trans("SuffixSessionName").' (DOLSESSID_...)</b>: '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
|
||||
print $form->textwithpicto('', $htmltext);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
|
|
|
|||
|
|
@ -1155,12 +1155,12 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu =
|
|||
$newmenu->add('/admin/system/database.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoDatabase'), 1);
|
||||
$newmenu->add("/admin/system/perf.php?mainmenu=home&leftmenu=admintools", $langs->trans("InfoPerf"), 1);
|
||||
$newmenu->add("/admin/system/security.php?mainmenu=home&leftmenu=admintools", $langs->trans("InfoSecurity"), 1);
|
||||
$newmenu->add("/admin/tools/listevents.php?mainmenu=home&leftmenu=admintools", $langs->trans("Audit"), 1);
|
||||
$newmenu->add("/admin/tools/listsessions.php?mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"), 1);
|
||||
$newmenu->add("/admin/tools/dolibarr_export.php?mainmenu=home&leftmenu=admintools", $langs->trans("Backup"), 1);
|
||||
$newmenu->add("/admin/tools/dolibarr_import.php?mainmenu=home&leftmenu=admintools", $langs->trans("Restore"), 1);
|
||||
$newmenu->add("/admin/tools/update.php?mainmenu=home&leftmenu=admintools", $langs->trans("MenuUpgrade"), 1);
|
||||
$newmenu->add("/admin/tools/purge.php?mainmenu=home&leftmenu=admintools", $langs->trans("Purge"), 1);
|
||||
$newmenu->add("/admin/tools/listevents.php?mainmenu=home&leftmenu=admintools", $langs->trans("Audit"), 1);
|
||||
$newmenu->add("/admin/tools/listsessions.php?mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"), 1);
|
||||
$newmenu->add('/admin/system/about.php?mainmenu=home&leftmenu=admintools', $langs->trans('ExternalResources'), 1);
|
||||
|
||||
if (isModEnabled('product') || isModEnabled('service')) {
|
||||
|
|
|
|||
|
|
@ -321,3 +321,5 @@ BatchNotFound=Lot / serial not found for this product
|
|||
StockMovementWillBeRecorded=Stock movement will be recorded
|
||||
StockMovementNotYetRecorded=Stock movement will not be affected by this step
|
||||
WarningThisWIllAlsoDeleteStock=Warning, this will also destroy all quantities in stock in the warehouse
|
||||
DeleteBatch=Delete lot/serial
|
||||
ConfirmDeleteBatch=Are you sure you want to delete lot/serial ?
|
||||
|
|
@ -102,8 +102,8 @@ class Productlot extends CommonObject
|
|||
*/
|
||||
public $fields = array(
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'),
|
||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1, 'searchall'=>1),
|
||||
'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1),
|
||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'picto' => 'product', 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'maxwidth150'),
|
||||
'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1, 'picto'=>'lot'),
|
||||
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
|
||||
'sellby' => array('type'=>'date', 'label'=>'SellByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_SELLBY)?1:0', 'visible'=>5, 'position'=>60),
|
||||
'eol_date' => array('type'=>'date', 'label'=>'EndOfLife', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_TRACEABILITY)?0:1', 'visible'=>5, 'position'=>70),
|
||||
|
|
@ -113,7 +113,7 @@ class Productlot extends CommonObject
|
|||
//'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_QUALITYCONTROL)?1:0', 'visible'=>5, 'position'=>110),
|
||||
'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62),
|
||||
'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 215),
|
||||
'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => -1, 'position' => 310),
|
||||
'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => -2, 'position' => 310),
|
||||
'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500),
|
||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
|
||||
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'),
|
||||
|
|
@ -181,7 +181,8 @@ class Productlot extends CommonObject
|
|||
*/
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$error = 0;
|
||||
|
|
@ -208,6 +209,11 @@ class Productlot extends CommonObject
|
|||
}
|
||||
|
||||
// Check parameters
|
||||
if ($this->batch === '') {
|
||||
$this->errors[] = $langs->trans("ErrorBadValueForBatch");
|
||||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
// Insert request
|
||||
|
|
@ -490,6 +496,47 @@ class Productlot extends CommonObject
|
|||
|
||||
$this->db->begin();
|
||||
|
||||
// Check there is no stock for this lot
|
||||
$sql = "SELECT pb.rowid FROM ".$this->db->prefix()."product_batch as pb, ".$this->db->prefix()."product_stock as ps";
|
||||
$sql .= " WHERE pb.fk_product_stock = ps.rowid AND pb.batch = '".$this->db->escape($this->batch)."'";
|
||||
$sql .= " AND ps.fk_product = ".((int) $this->fk_product);
|
||||
$sql .= $this->db->plimit(1);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$error++;
|
||||
$this->errors[] = 'Error Lot is used in stock (ID = '.$obj->rowid.'). Deletion not possible.';
|
||||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->errors[] = 'Error '.$this->db->lasterror();
|
||||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
|
||||
// Check there is no movement for this lot
|
||||
$sql = "SELECT sm.rowid FROM ".$this->db->prefix()."stock_mouvement as sm";
|
||||
$sql .= " WHERE sm.batch = '".$this->db->escape($this->batch)."'";
|
||||
$sql .= " AND sm.fk_product = ".((int) $this->fk_product);
|
||||
$sql .= $this->db->plimit(1);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$error++;
|
||||
$this->errors[] = 'Error Lot was used in a stock movement (ID '.$obj->rowid.'). Deletion not possible.';
|
||||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->errors[] = 'Error '.$this->db->lasterror();
|
||||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
|
||||
// TODO
|
||||
//if (!$error) {
|
||||
//if (!$notrigger) {
|
||||
// Uncomment this and change PRODUCTLOT to your own tag if you
|
||||
|
|
|
|||
|
|
@ -480,16 +480,21 @@ $titletoadd = $langs->trans("Select");
|
|||
$buttonrecord = $langs->trans("RecordMovements");
|
||||
$titletoaddnoent = $langs->transnoentitiesnoconv("Select");
|
||||
$buttonrecordnoent = $langs->transnoentitiesnoconv("RecordMovements");
|
||||
print '<span class="opacitymedium">'.$langs->trans("SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).'</span><br>';
|
||||
print '<span class="opacitymedium">'.$langs->trans("SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).'</span>';
|
||||
|
||||
print '<br>';
|
||||
//print '<br>';
|
||||
|
||||
// Form to upload a file
|
||||
print '<form name="userfile" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" METHOD="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="importCSV">';
|
||||
if (!empty($conf->dol_optimize_smallscreen)) {
|
||||
print '<br>';
|
||||
}
|
||||
print '<span class="opacitymedium">';
|
||||
print $langs->trans("or").' ';
|
||||
print $langs->trans("or");
|
||||
print ' ';
|
||||
$importcsv = new ImportCsv($db, 'massstocklist');
|
||||
print $form->textwithpicto($langs->trans('SelectAStockMovementFileToImport'), $langs->transnoentitiesnoconv("InfoTemplateImport", $importcsv->separator));
|
||||
print '</span>';
|
||||
|
|
@ -501,7 +506,7 @@ if ($maxmin > 0) {
|
|||
}
|
||||
print '<input type="file" name="userfile" size="20" maxlength="80"> ';
|
||||
$out = (empty($conf->global->MAIN_UPLOAD_DOC) ? ' disabled' : '');
|
||||
print '<input type="submit" class="button small" value="'.$langs->trans("ImportFromCSV").'"'.$out.' name="sendit">';
|
||||
print '<input type="submit" class="button small smallpaddingimp" value="'.$langs->trans("ImportFromCSV").'"'.$out.' name="sendit">';
|
||||
$out = '';
|
||||
if (!empty($conf->global->MAIN_UPLOAD_DOC)) {
|
||||
$max = $conf->global->MAIN_UPLOAD_DOC; // In Kb
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ $upload_dir = $conf->productbatch->multidir_output[$conf->entity];
|
|||
|
||||
$permissiontoread = $usercanread;
|
||||
$permissiontoadd = $usercancreate;
|
||||
//$permissiontodelete = $usercandelete;
|
||||
$permissiontodelete = $usercandelete;
|
||||
|
||||
// Security check
|
||||
if (empty($conf->productbatch->enabled)) {
|
||||
|
|
@ -375,8 +375,8 @@ $formfile = new FormFile($db);
|
|||
|
||||
$title = $langs->trans("ProductLot");
|
||||
$help_url = '';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
|
||||
// Part to create
|
||||
|
|
@ -519,9 +519,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print dol_get_fiche_end();
|
||||
|
||||
// Link to other lists
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/reassortlot.php?sref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.$langs->trans("ShowCurrentStockOfLot").'</a><br>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/reassortlot.php?sref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.img_object('', 'stock', 'class="pictofixedwidth"').$langs->trans("ShowCurrentStockOfLot").'</a><br>';
|
||||
print '<br>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?search_product_ref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.$langs->trans("ShowLogOfMovementIfLot").'</a><br>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?search_product_ref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.img_object('', 'movement', 'class="pictofixedwidth"').$langs->trans("ShowLogOfMovementIfLot").'</a><br>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
|
@ -540,9 +540,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a></div>'."\n";
|
||||
}
|
||||
|
||||
print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->rights->stock->supprimer);
|
||||
*/
|
||||
print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
|
||||
}
|
||||
|
||||
print '</div>'."\n";
|
||||
|
|
|
|||
Loading…
Reference in a new issue