Merge branch 'NEW_stockstransfers' of github.com:atm-gauthier/dolibarr into NEW_stockstransfers
This commit is contained in:
commit
6983da8c84
@ -70,13 +70,11 @@ $setupnotempty = 0;
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ((float) DOL_VERSION >= 6)
|
||||
{
|
||||
if ((float) DOL_VERSION >= 6) {
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
}
|
||||
|
||||
if ($action == 'updateMask')
|
||||
{
|
||||
if ($action == 'updateMask') {
|
||||
$maskconststocktransfer = GETPOST('maskconststocktransfer', 'alpha');
|
||||
$maskstocktransfer = GETPOST('maskStockTransfer', 'alpha');
|
||||
|
||||
@ -84,14 +82,12 @@ if ($action == 'updateMask')
|
||||
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action == 'specimen')
|
||||
{
|
||||
} elseif ($action == 'specimen') {
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
||||
@ -101,25 +97,21 @@ if ($action == 'updateMask')
|
||||
// Search template files
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$file = dol_buildpath($reldir."core/modules/stocktransfer/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
if ($filefound) {
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($tmpobject, $langs) > 0)
|
||||
{
|
||||
if ($module->write_file($tmpobject, $langs) > 0) {
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
@ -133,28 +125,23 @@ if ($action == 'updateMask')
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
elseif ($action == 'set')
|
||||
{
|
||||
elseif ($action == 'set') {
|
||||
$ret = addDocumentModel($value, 'stocktransfer', $label, $scandir);
|
||||
} elseif ($action == 'del')
|
||||
{
|
||||
} elseif ($action == 'del') {
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($ret > 0) {
|
||||
$constforval = strtoupper($tmpobjectkey).'_ADDON_PDF';
|
||||
if ($conf->global->$constforval == "$value") dolibarr_del_const($db, $constforval, $conf->entity);
|
||||
}
|
||||
}
|
||||
|
||||
// Set default model
|
||||
elseif ($action == 'setdoc')
|
||||
{
|
||||
elseif ($action == 'setdoc') {
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
$constforval = strtoupper($tmpobjectkey).'_ADDON_PDF';
|
||||
if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity))
|
||||
{
|
||||
if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
|
||||
// The constant that was read before the new set
|
||||
// We therefore requires a variable to have a coherent view
|
||||
$conf->global->$constforval = $value;
|
||||
@ -162,12 +149,10 @@ elseif ($action == 'setdoc')
|
||||
|
||||
// On active le modele
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($ret > 0) {
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
}
|
||||
} elseif ($action == 'setmod')
|
||||
{
|
||||
} elseif ($action == 'setmod') {
|
||||
// TODO Check if numbering module chosen can be activated
|
||||
// by calling method canBeActivated
|
||||
$tmpobjectkey = GETPOST('object');
|
||||
@ -279,19 +264,14 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
|
||||
clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$dir = dol_buildpath($reldir."core/modules/".$moduledir);
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php')
|
||||
{
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
require_once $dir.'/'.$file.'.php';
|
||||
@ -302,8 +282,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
if ($module->isEnabled())
|
||||
{
|
||||
if ($module->isEnabled()) {
|
||||
dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
|
||||
|
||||
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
|
||||
@ -320,8 +299,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
|
||||
print '<td class="center">';
|
||||
$constforvar = 'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).'_ADDON';
|
||||
if ($conf->global->$constforvar == $file)
|
||||
{
|
||||
if ($conf->global->$constforvar == $file) {
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
} else {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&object='.strtolower($myTmpObjectKey).'&value='.$file.'">';
|
||||
@ -380,12 +358,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
$sql .= " WHERE type = '".$type."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num_rows = $db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
while ($i < $num_rows) {
|
||||
$array = $db->fetch_array($resql);
|
||||
array_push($def, $array[0]);
|
||||
$i++;
|
||||
@ -406,31 +382,23 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
|
||||
clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach (array('', '/doc') as $valdir)
|
||||
{
|
||||
foreach ($dirmodels as $reldir) {
|
||||
foreach (array('', '/doc') as $valdir) {
|
||||
$realpath = $reldir."core/modules/".$moduledir.$valdir;
|
||||
$dir = dol_buildpath($realpath);
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
$filelist[] = $file;
|
||||
}
|
||||
closedir($handle);
|
||||
arsort($filelist);
|
||||
|
||||
foreach ($filelist as $file)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
foreach ($filelist as $file) {
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
|
||||
if (file_exists($dir.'/'.$file)) {
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
@ -441,8 +409,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
if ($modulequalified) {
|
||||
print '<tr class="oddeven"><td width="100">';
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td><td>\n";
|
||||
@ -451,8 +418,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
print '</td>';
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
if (in_array($name, $def)) {
|
||||
print '<td class="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
|
||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||
@ -467,8 +433,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
// Default
|
||||
print '<td class="center">';
|
||||
$constforvar = 'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).'_ADDON';
|
||||
if ($conf->global->$constforvar == $name)
|
||||
{
|
||||
if ($conf->global->$constforvar == $name) {
|
||||
print img_picto($langs->trans("Default"), 'on');
|
||||
} else {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
@ -478,8 +443,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
if ($module->type == 'pdf')
|
||||
{
|
||||
if ($module->type == 'pdf') {
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
}
|
||||
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
|
||||
@ -494,8 +458,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||
|
||||
// Preview
|
||||
print '<td class="center">';
|
||||
if ($module->type == 'pdf')
|
||||
{
|
||||
if ($module->type == 'pdf') {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'generic').'</a>';
|
||||
} else {
|
||||
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
|
||||
|
||||
@ -1641,7 +1641,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
|
||||
}
|
||||
}
|
||||
|
||||
if($conf->stocktransfer->enabled) {
|
||||
if ($conf->stocktransfer->enabled) {
|
||||
$newmenu->add('/product/stock/stocktransfer/stocktransfer_list.php', $langs->trans("ModuleStockTransferName"), 0, $user->rights->stocktransfer->stocktransfer->read, '', $mainmenu, 'stocktransfer', 0, '', '', '', img_picto('', 'stock', 'class="pictofixedwidth"'));
|
||||
$newmenu->add('/product/stock/stocktransfer/stocktransfer_card.php?action=create', $langs->trans('StockTransferNew'), 1, $user->rights->stocktransfer->stocktransfer->write);
|
||||
$newmenu->add('/product/stock/stocktransfer/stocktransfer_list.php', $langs->trans('List'), 1, $user->rights->stocktransfer->stocktransfer->read);
|
||||
|
||||
@ -348,26 +348,26 @@ class modStockTransfer extends DolibarrModules
|
||||
// 0=Menu for internal users, 1=external users, 2=both
|
||||
'user'=>2
|
||||
);
|
||||
$this->menu[$r++]=array(
|
||||
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||
'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=stock',
|
||||
// This is a Left menu entry
|
||||
'type'=>'left',
|
||||
'titre'=>$langs->trans('StockTransferList'),
|
||||
'mainmenu'=>'products',
|
||||
'leftmenu'=>'stocktransfer_stocktransferlist',
|
||||
'url'=>'/stocktransfer/stocktransfer_list.php',
|
||||
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'langs'=>'stocktransfer@stocktransfer',
|
||||
'position'=>1100+$r,
|
||||
// Define condition to show or hide menu entry. Use '$conf->stocktransfer->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||
'enabled'=>'$conf->stocktransfer->enabled',
|
||||
// Use 'perms'=>'$user->rights->stocktransfer->level1->level2' if you want your menu with a permission rules
|
||||
'perms'=>'1',
|
||||
'target'=>'',
|
||||
// 0=Menu for internal users, 1=external users, 2=both
|
||||
'user'=>2,
|
||||
);*/
|
||||
$this->menu[$r++]=array(
|
||||
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||
'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=stock',
|
||||
// This is a Left menu entry
|
||||
'type'=>'left',
|
||||
'titre'=>$langs->trans('StockTransferList'),
|
||||
'mainmenu'=>'products',
|
||||
'leftmenu'=>'stocktransfer_stocktransferlist',
|
||||
'url'=>'/stocktransfer/stocktransfer_list.php',
|
||||
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'langs'=>'stocktransfer@stocktransfer',
|
||||
'position'=>1100+$r,
|
||||
// Define condition to show or hide menu entry. Use '$conf->stocktransfer->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||
'enabled'=>'$conf->stocktransfer->enabled',
|
||||
// Use 'perms'=>'$user->rights->stocktransfer->level1->level2' if you want your menu with a permission rules
|
||||
'perms'=>'1',
|
||||
'target'=>'',
|
||||
// 0=Menu for internal users, 1=external users, 2=both
|
||||
'user'=>2,
|
||||
);*/
|
||||
|
||||
/* END MODULEBUILDER LEFTMENU STOCKTRANSFER */
|
||||
|
||||
@ -464,13 +464,11 @@ class modStockTransfer extends DolibarrModules
|
||||
$dirodt=DOL_DATA_ROOT.'/doctemplates/stocktransfer';
|
||||
$dest=$dirodt.'/template_stocktransfers.odt';
|
||||
|
||||
if (file_exists($src) && ! file_exists($dest))
|
||||
{
|
||||
if (file_exists($src) && ! file_exists($dest)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_mkdir($dirodt);
|
||||
$result=dol_copy($src, $dest, 0, 0);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$langs->load("errors");
|
||||
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
|
||||
return 0;
|
||||
@ -489,20 +487,21 @@ class modStockTransfer extends DolibarrModules
|
||||
// Rôles
|
||||
$resql = $db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "internal"');
|
||||
$res = $db->fetch_object($resql);
|
||||
if(empty($res)) $db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.$this->getNextId().', "StockTransfer", "internal", "STRESP", "Responsable du transfert de stocks", 1, NULL, 0)');
|
||||
if (empty($res)) $db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.$this->getNextId().', "StockTransfer", "internal", "STRESP", "Responsable du transfert de stocks", 1, NULL, 0)');
|
||||
|
||||
$resql = $db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STFROM" AND element = "StockTransfer" AND source = "external"');
|
||||
$res = $db->fetch_object($resql);
|
||||
if(empty($res)) $db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.$this->getNextId().', "StockTransfer", "external", "STFROM", "Contact expéditeur transfert de stocks", 1, NULL, 0)');
|
||||
if (empty($res)) $db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.$this->getNextId().', "StockTransfer", "external", "STFROM", "Contact expéditeur transfert de stocks", 1, NULL, 0)');
|
||||
|
||||
$resql = $db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "external"');
|
||||
$res = $db->fetch_object($resql);
|
||||
if(empty($res)) $db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.$this->getNextId().', "StockTransfer", "external", "STDEST", "Contact destinataire transfert de stocks", 1, NULL, 0)');
|
||||
if (empty($res)) $db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.$this->getNextId().', "StockTransfer", "external", "STDEST", "Contact destinataire transfert de stocks", 1, NULL, 0)');
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
|
||||
function getNextId() {
|
||||
function getNextId()
|
||||
{
|
||||
|
||||
global $db;
|
||||
|
||||
@ -510,8 +509,7 @@ class modStockTransfer extends DolibarrModules
|
||||
$newid = 0;
|
||||
$sql = "SELECT max(rowid) newid from ".MAIN_DB_PREFIX."c_type_contact";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$obj = $db->fetch_object($result);
|
||||
$newid = ($obj->newid + 1);
|
||||
} else {
|
||||
|
||||
@ -209,23 +209,18 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
// Loop on each lines to detect if there is at least one image to show
|
||||
$realpatharray = array();
|
||||
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) {
|
||||
$objphoto = new Product($this->db);
|
||||
|
||||
for ($i = 0; $i < $nblines; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nblines; $i++) {
|
||||
if (empty($object->lines[$i]->fk_product)) continue;
|
||||
|
||||
$objphoto = new Product($this->db);
|
||||
$objphoto->fetch($object->lines[$i]->fk_product);
|
||||
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
|
||||
{
|
||||
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
|
||||
$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
|
||||
$dir = $conf->product->dir_output.'/'.$pdir;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
|
||||
$dir = $conf->product->dir_output.'/'.$pdir;
|
||||
}
|
||||
@ -235,17 +230,12 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
|
||||
if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
|
||||
// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
|
||||
if ($obj['photo_vignette'])
|
||||
{
|
||||
if ($obj['photo_vignette']) {
|
||||
$filename = $obj['photo_vignette'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$filename = $obj['photo'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$filename = $obj['photo'];
|
||||
}
|
||||
|
||||
@ -259,35 +249,27 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
if (count($realpatharray) == 0) $this->posxpicture = $this->posxqty;
|
||||
|
||||
if ($conf->stocktransfer->dir_output)
|
||||
{
|
||||
if ($conf->stocktransfer->dir_output) {
|
||||
// Definition de $dir et $file
|
||||
if ($object->specimen)
|
||||
{
|
||||
if ($object->specimen) {
|
||||
$dir = $conf->stocktransfer->dir_output;
|
||||
$file = $dir."/SPECIMEN.pdf";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$stocktransferref = dol_sanitizeFileName($object->ref);
|
||||
$dir = $conf->stocktransfer->dir_output.'/'.$object->element."/".$stocktransferref;
|
||||
$file = $dir."/".$stocktransferref.".pdf";
|
||||
}
|
||||
|
||||
if (!file_exists($dir))
|
||||
{
|
||||
if (dol_mkdir($dir) < 0)
|
||||
{
|
||||
if (!file_exists($dir)) {
|
||||
if (dol_mkdir($dir) < 0) {
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($dir))
|
||||
{
|
||||
if (file_exists($dir)) {
|
||||
// Add pdfgeneration hook
|
||||
if (!is_object($hookmanager))
|
||||
{
|
||||
if (!is_object($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
@ -307,15 +289,13 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
|
||||
$pdf->SetAutoPageBreak(1, 0);
|
||||
|
||||
if (class_exists('TCPDF'))
|
||||
{
|
||||
if (class_exists('TCPDF')) {
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
}
|
||||
$pdf->SetFont(pdf_getPDFFont($outputlangs));
|
||||
// Set path to the background PDF File
|
||||
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
|
||||
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
|
||||
$tplidx = $pdf->importPage(1);
|
||||
}
|
||||
@ -351,11 +331,9 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
// Incoterm
|
||||
$height_incoterms = 0;
|
||||
if ($conf->incoterm->enabled)
|
||||
{
|
||||
if ($conf->incoterm->enabled) {
|
||||
$desc_incoterms = $object->getIncotermsForPDF();
|
||||
if ($desc_incoterms)
|
||||
{
|
||||
if ($desc_incoterms) {
|
||||
$tab_top = 88;
|
||||
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
@ -372,8 +350,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($object->note_public) || !empty($object->tracking_number))
|
||||
{
|
||||
if (!empty($object->note_public) || !empty($object->tracking_number)) {
|
||||
$tab_top = 88 + $height_incoterms;
|
||||
$tab_top_alt = $tab_top;
|
||||
|
||||
@ -382,24 +359,20 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
//$tab_top_alt += 1;
|
||||
|
||||
// Tracking number
|
||||
if (!empty($object->tracking_number))
|
||||
{
|
||||
if (!empty($object->tracking_number)) {
|
||||
$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
|
||||
$tab_top_alt = $pdf->GetY();
|
||||
|
||||
$object->getUrlTrackingStatus($object->tracking_number);
|
||||
if (!empty($object->tracking_url))
|
||||
{
|
||||
if ($object->shipping_method_id > 0)
|
||||
{
|
||||
if (!empty($object->tracking_url)) {
|
||||
if ($object->shipping_method_id > 0) {
|
||||
// Get code using getLabelFromKey
|
||||
$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
|
||||
$label = '';
|
||||
if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
|
||||
$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
|
||||
//var_dump($object->tracking_url != $object->tracking_number);exit;
|
||||
if ($object->tracking_url != $object->tracking_number)
|
||||
{
|
||||
if ($object->tracking_url != $object->tracking_number) {
|
||||
$label .= " : ";
|
||||
$label .= $object->tracking_url;
|
||||
}
|
||||
@ -412,8 +385,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
|
||||
// Notes
|
||||
if (!empty($object->note_public))
|
||||
{
|
||||
if (!empty($object->note_public)) {
|
||||
$pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
|
||||
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
|
||||
}
|
||||
@ -427,9 +399,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
$tab_height = $tab_height - $height_note;
|
||||
$tab_top = $nexY + 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$height_note = 0;
|
||||
}
|
||||
|
||||
@ -439,8 +409,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
$TCacheEntrepots=array();
|
||||
// Loop on each lines
|
||||
for ($i = 0; $i < $nblines; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nblines; $i++) {
|
||||
$curY = $nexY;
|
||||
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
@ -458,8 +427,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$posYAfterDescription = 0;
|
||||
|
||||
// We start with Photo of product line
|
||||
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
|
||||
{
|
||||
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
|
||||
$pdf->AddPage('', '', true);
|
||||
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
@ -470,12 +438,10 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
// Allows data in the first page if description is long enough to break in multiples pages
|
||||
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
|
||||
$showpricebeforepagebreak = 1;
|
||||
else
|
||||
$showpricebeforepagebreak = 0;
|
||||
else $showpricebeforepagebreak = 0;
|
||||
}
|
||||
|
||||
if (isset($imglinesize['width']) && isset($imglinesize['height']))
|
||||
{
|
||||
if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
|
||||
$curX = $this->posxpicture - 1;
|
||||
$pdf->Image($realpatharray[$i], $curX + (($this->posxqty - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
|
||||
// $pdf->Image does not increase value return by getY, so we save it manually
|
||||
@ -486,7 +452,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$curX = $this->posxdesc - 1;
|
||||
|
||||
$pdf->startTransaction();
|
||||
if(method_exists($object->lines[$i], 'fetch_product')) {
|
||||
if (method_exists($object->lines[$i], 'fetch_product')) {
|
||||
$object->lines[$i]->fetch_product();
|
||||
$object->lines[$i]->label = $object->lines[$i]->product->label;
|
||||
$object->lines[$i]->description = $object->lines[$i]->product->description;
|
||||
@ -495,8 +461,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
|
||||
|
||||
$pageposafter = $pdf->getPage();
|
||||
if ($pageposafter > $pageposbefore) // There is a pagebreak
|
||||
{
|
||||
if ($pageposafter > $pageposbefore) { // There is a pagebreak
|
||||
$pdf->rollbackTransaction(true);
|
||||
$pageposafter = $pageposbefore;
|
||||
//print $pageposafter.'-'.$pageposbefore;exit;
|
||||
@ -506,28 +471,22 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$pageposafter = $pdf->getPage();
|
||||
$posyafter = $pdf->GetY();
|
||||
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
|
||||
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
|
||||
{
|
||||
if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
|
||||
{
|
||||
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
|
||||
if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
|
||||
$pdf->AddPage('', '', true);
|
||||
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
$pdf->setPage($pageposafter + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// We found a page break
|
||||
|
||||
// Allows data in the first page if description is long enough to break in multiples pages
|
||||
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
|
||||
$showpricebeforepagebreak = 1;
|
||||
else
|
||||
$showpricebeforepagebreak = 0;
|
||||
else $showpricebeforepagebreak = 0;
|
||||
}
|
||||
}
|
||||
else // No pagebreak
|
||||
} else // No pagebreak
|
||||
{
|
||||
$pdf->commitTransaction();
|
||||
}
|
||||
@ -555,7 +514,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
$pdf->SetXY($this->posxqty, $curY);
|
||||
// Lot / série
|
||||
if(!empty($conf->productbatch->enabled)) {
|
||||
if (!empty($conf->productbatch->enabled)) {
|
||||
$pdf->SetXY($this->posxlot, $curY);
|
||||
$pdf->MultiCell(($this->posxqty - $this->posxlot), 3, $object->lines[$i]->batch, '', 'C');
|
||||
}
|
||||
@ -567,7 +526,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
// Warehouse source
|
||||
$wh_source = new Entrepot($db);
|
||||
if(!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
|
||||
if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
|
||||
else {
|
||||
$wh_source->fetch($object->lines[$i]->fk_warehouse_source);
|
||||
$TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source;
|
||||
@ -577,7 +536,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
// Warehouse destination
|
||||
$wh_destination = new Entrepot($db);
|
||||
if(!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
|
||||
if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
|
||||
else {
|
||||
$wh_destination->fetch($object->lines[$i]->fk_warehouse_destination);
|
||||
$TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination;
|
||||
@ -585,8 +544,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$pdf->SetXY($this->posxwarehousedestination, $curY);
|
||||
$pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination), 3, $wh_destination->ref.(!empty($wh_destination->lieu) ? ' - '.$wh_destination->lieu : ''), '', 'C');
|
||||
|
||||
if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT))
|
||||
{
|
||||
if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
|
||||
$pdf->SetXY($this->posxpuht, $curY);
|
||||
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
|
||||
|
||||
@ -598,8 +556,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
if ($weighttxt && $voltxt) $nexY += 2;
|
||||
|
||||
// Add line
|
||||
if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
|
||||
$pdf->setPage($pageposafter);
|
||||
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
|
||||
//$pdf->SetDrawColor(190,190,200);
|
||||
@ -608,15 +565,11 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
|
||||
// Detect if some page were added automatically and output _tableau for past pages
|
||||
while ($pagenb < $pageposafter)
|
||||
{
|
||||
while ($pagenb < $pageposafter) {
|
||||
$pdf->setPage($pagenb);
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
if ($pagenb == 1) {
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
|
||||
}
|
||||
$this->_pagefoot($pdf, $object, $outputlangs, 1);
|
||||
@ -625,14 +578,10 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
|
||||
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
}
|
||||
if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
|
||||
{
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
|
||||
if ($pagenb == 1) {
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
|
||||
}
|
||||
$this->_pagefoot($pdf, $object, $outputlangs, 1);
|
||||
@ -645,13 +594,10 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
|
||||
// Show square
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
if ($pagenb == 1) {
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
|
||||
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
|
||||
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
@ -672,8 +618,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0)
|
||||
{
|
||||
if ($reshook < 0) {
|
||||
$this->error = $hookmanager->error;
|
||||
$this->errors = $hookmanager->errors;
|
||||
}
|
||||
@ -684,15 +629,11 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // No error
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
|
||||
return 0;
|
||||
}
|
||||
@ -745,8 +686,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$totalOrdered = $tmparray['ordered'];
|
||||
$totalToShip = $tmparray['toship'];
|
||||
// Set trueVolume and volume_units not currently stored into database
|
||||
if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
|
||||
{
|
||||
if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
|
||||
$object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
|
||||
$object->volume_units = $object->size_units * 3;
|
||||
}
|
||||
@ -760,20 +700,17 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
|
||||
|
||||
if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED))
|
||||
{
|
||||
if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) {
|
||||
$pdf->SetXY($this->posxwarehousesource, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($this->posxwarehousedestination - $this->posxwarehousesource, $tab2_hl, $totalOrdered, 0, 'C', 1);
|
||||
}
|
||||
|
||||
if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_QTYTOSHIP))
|
||||
{
|
||||
if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_QTYTOSHIP)) {
|
||||
$pdf->SetXY($this->posxwarehousedestination, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($this->posxpuht - $this->posxwarehousedestination, $tab2_hl, $totalToShip, 0, 'C', 1);
|
||||
}
|
||||
|
||||
if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT))
|
||||
{
|
||||
if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
|
||||
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
|
||||
|
||||
@ -781,18 +718,15 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
|
||||
}
|
||||
|
||||
if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME))
|
||||
{
|
||||
if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
|
||||
// Total Weight
|
||||
if ($totalWeighttoshow)
|
||||
{
|
||||
if ($totalWeighttoshow) {
|
||||
$pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
|
||||
|
||||
$index++;
|
||||
}
|
||||
if ($totalVolumetoshow)
|
||||
{
|
||||
if ($totalVolumetoshow) {
|
||||
$pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
|
||||
|
||||
@ -839,15 +773,14 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$pdf->SetDrawColor(128, 128, 128);
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
|
||||
if (empty($hidetop))
|
||||
{
|
||||
if (empty($hidetop)) {
|
||||
$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
|
||||
|
||||
$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
|
||||
$pdf->MultiCell($this->posxwarehousesource - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
|
||||
}
|
||||
|
||||
if(!empty($conf->productbatch->enabled) && $this->atLeastOneBatch) {
|
||||
if (!empty($conf->productbatch->enabled) && $this->atLeastOneBatch) {
|
||||
$pdf->line($this->posxlot - 1, $tab_top, $this->posxlot - 1, $tab_top + $tab_height);
|
||||
if (empty($hidetop)) {
|
||||
$pdf->SetXY($this->posxlot - 8, $tab_top + 1);
|
||||
@ -856,23 +789,20 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
|
||||
$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
if (empty($hidetop)) {
|
||||
$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
|
||||
$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), 2, $outputlangs->transnoentities("Qty"), '', 'C');
|
||||
}
|
||||
|
||||
$pdf->line($this->posxwarehousesource - 1, $tab_top, $this->posxwarehousesource - 1, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
if (empty($hidetop)) {
|
||||
$pdf->SetXY($this->posxwarehousesource - 1, $tab_top + 1);
|
||||
$pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 2, $outputlangs->transnoentities("WarehouseSource"), '', 'C');
|
||||
}
|
||||
|
||||
|
||||
$pdf->line($this->posxwarehousedestination - 1, $tab_top, $this->posxwarehousedestination - 1, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
if (empty($hidetop)) {
|
||||
$pdf->SetXY($this->posxwarehousedestination-2.5, $tab_top + 1);
|
||||
$pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination+4), 2, $outputlangs->transnoentities("WarehouseTarget"), '', 'C');
|
||||
}
|
||||
@ -894,18 +824,18 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}*/
|
||||
}
|
||||
|
||||
function atLeastOneBatch($object) {
|
||||
function atLeastOneBatch($object)
|
||||
{
|
||||
|
||||
$atLeastOneBatch = false;
|
||||
|
||||
foreach ($object->lines as $line) {
|
||||
if(!empty($line->batch)) {
|
||||
if (!empty($line->batch)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||
@ -929,8 +859,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
|
||||
|
||||
// Show Draft Watermark
|
||||
if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
|
||||
{
|
||||
if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
|
||||
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
|
||||
}
|
||||
|
||||
@ -947,47 +876,36 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
|
||||
// Logo
|
||||
$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
|
||||
if ($this->emetteur->logo)
|
||||
{
|
||||
if (is_readable($logo))
|
||||
{
|
||||
if ($this->emetteur->logo) {
|
||||
if (is_readable($logo)) {
|
||||
$height = pdf_getHeightForLogo($logo);
|
||||
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$pdf->SetTextColor(200, 0, 0);
|
||||
$pdf->SetFont('', 'B', $default_font_size - 2);
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
|
||||
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$text = $this->emetteur->name;
|
||||
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
}
|
||||
|
||||
// Show barcode
|
||||
if (!empty($conf->barcode->enabled))
|
||||
{
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$posx = 105;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$posx = $this->marge_gauche + 3;
|
||||
}
|
||||
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
|
||||
if (!empty($conf->barcode->enabled))
|
||||
{
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
|
||||
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
|
||||
//$pdf->Image($logo,10, 5, 0, 24);
|
||||
}
|
||||
|
||||
$pdf->SetDrawColor(128, 128, 128);
|
||||
if (!empty($conf->barcode->enabled))
|
||||
{
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
|
||||
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
|
||||
//$pdf->Image($logo,10, 5, 0, 24);
|
||||
@ -1012,8 +930,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
|
||||
|
||||
// Date reelle depart
|
||||
if (!empty($object->date_prevue_depart))
|
||||
{
|
||||
if (!empty($object->date_prevue_depart)) {
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
@ -1021,8 +938,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
|
||||
// Date reelle arrivée
|
||||
if (!empty($object->date_prevue_arrivee))
|
||||
{
|
||||
if (!empty($object->date_prevue_arrivee)) {
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
@ -1030,8 +946,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
|
||||
// Date reelle depart
|
||||
if (!empty($object->date_reelle_depart))
|
||||
{
|
||||
if (!empty($object->date_reelle_depart)) {
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
@ -1039,16 +954,14 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
|
||||
// Date reelle arrivée
|
||||
if (!empty($object->date_reelle_arrivee))
|
||||
{
|
||||
if (!empty($object->date_reelle_arrivee)) {
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R');
|
||||
}
|
||||
|
||||
if (!empty($object->thirdparty->code_client))
|
||||
{
|
||||
if (!empty($object->thirdparty->code_client)) {
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
@ -1064,15 +977,13 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$origin_id = $object->origin_id;
|
||||
|
||||
// TODO move to external function
|
||||
if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
|
||||
{
|
||||
if (!empty($conf->$origin->enabled)) { // commonly $origin='commande'
|
||||
$outputlangs->load('orders');
|
||||
|
||||
$classname = ucfirst($origin);
|
||||
$linkedobject = new $classname($this->db);
|
||||
$result = $linkedobject->fetch($origin_id);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
|
||||
|
||||
$pdf->SetFont('', '', $default_font_size - 2);
|
||||
@ -1087,8 +998,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
}
|
||||
}
|
||||
|
||||
if ($showaddress)
|
||||
{
|
||||
if ($showaddress) {
|
||||
// Sender properties
|
||||
$carac_emetteur = '';
|
||||
// Add internal contact of origin element if defined
|
||||
@ -1096,8 +1006,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$arrayidcontact = $object->getIdContact('external', 'STFROM');
|
||||
|
||||
$usecontact = false;
|
||||
if (count($arrayidcontact) > 0)
|
||||
{
|
||||
if (count($arrayidcontact) > 0) {
|
||||
/*$object->fetch_user(reset($arrayidcontact));
|
||||
$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
|
||||
$usecontact = true;
|
||||
@ -1107,9 +1016,9 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
if ($usecontact) $thirdparty = $object->contact;
|
||||
else $thirdparty = $this->emetteur;
|
||||
|
||||
if(!empty($thirdparty)) $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
||||
if (!empty($thirdparty)) $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
||||
|
||||
if($usecontact) $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
|
||||
if ($usecontact) $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
|
||||
else $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
|
||||
|
||||
// Show sender
|
||||
@ -1146,8 +1055,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
// If SHIPPING contact defined, we use it
|
||||
$usecontact = false;
|
||||
$arrayidcontact = $object->getIdContact('external', 'STDEST');
|
||||
if (count($arrayidcontact) > 0)
|
||||
{
|
||||
if (count($arrayidcontact) > 0) {
|
||||
$usecontact = true;
|
||||
$result = $object->fetch_contact($arrayidcontact[0]);
|
||||
}
|
||||
@ -1160,7 +1068,7 @@ class pdf_eagle extends ModelePdfStockTransfer
|
||||
$thirdparty = $object->thirdparty;
|
||||
}
|
||||
|
||||
if(!empty($thirdparty)) $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
||||
if (!empty($thirdparty)) $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
||||
|
||||
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
|
||||
|
||||
|
||||
@ -114,8 +114,7 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer
|
||||
/*$mysoc->code_client = $old_code_client;
|
||||
$mysoc->typent_code = $old_code_type;*/
|
||||
|
||||
if (!$numExample)
|
||||
{
|
||||
if (!$numExample) {
|
||||
$numExample = $langs->trans('NotConfigured');
|
||||
}
|
||||
return $numExample;
|
||||
@ -136,8 +135,7 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer
|
||||
// We get cursor rule
|
||||
$mask = $conf->global->STOCKTRANSFER_STOCKTRANSFER_ADVANCED_MASK;
|
||||
|
||||
if (!$mask)
|
||||
{
|
||||
if (!$mask) {
|
||||
$this->error = 'NotConfigured';
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -92,19 +92,16 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
}
|
||||
elseif ($object->ismultientitymanaged == 2) {
|
||||
} elseif ($object->ismultientitymanaged == 2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
|
||||
}
|
||||
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
|
||||
{
|
||||
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans('ErrorNumRefModel', $max);
|
||||
return false;
|
||||
@ -130,20 +127,16 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
}
|
||||
elseif ($object->ismultientitymanaged == 2) {
|
||||
} elseif ($object->ismultientitymanaged == 2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) $max = intval($obj->max);
|
||||
else $max = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dol_syslog("mod_stocktransfer_standard::getNextValue", LOG_DEBUG);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -196,23 +196,17 @@ class StockTransfer extends CommonObject
|
||||
}*/
|
||||
|
||||
// Unset fields that are disabled
|
||||
foreach ($this->fields as $key => $val)
|
||||
{
|
||||
if (isset($val['enabled']) && empty($val['enabled']))
|
||||
{
|
||||
foreach ($this->fields as $key => $val) {
|
||||
if (isset($val['enabled']) && empty($val['enabled'])) {
|
||||
unset($this->fields[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Translate some data of arrayofkeyval
|
||||
if (is_object($langs))
|
||||
{
|
||||
foreach ($this->fields as $key => $val)
|
||||
{
|
||||
if (is_array($val['arrayofkeyval']))
|
||||
{
|
||||
foreach ($val['arrayofkeyval'] as $key2 => $val2)
|
||||
{
|
||||
if (is_object($langs)) {
|
||||
foreach ($this->fields as $key => $val) {
|
||||
if (is_array($val['arrayofkeyval'])) {
|
||||
foreach ($val['arrayofkeyval'] as $key2 => $val2) {
|
||||
$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
|
||||
}
|
||||
}
|
||||
@ -229,9 +223,9 @@ class StockTransfer extends CommonObject
|
||||
*/
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
$this->status = (int)$this->status;
|
||||
if($this->fk_warehouse_source <= 0) $this->fk_warehouse_source = 0;
|
||||
if($this->fk_warehouse_destination <= 0) $this->fk_warehouse_destination = 0;
|
||||
$this->status = (int) $this->status;
|
||||
if ($this->fk_warehouse_source <= 0) $this->fk_warehouse_source = 0;
|
||||
if ($this->fk_warehouse_destination <= 0) $this->fk_warehouse_destination = 0;
|
||||
return $this->createCommon($user, $notrigger);
|
||||
}
|
||||
|
||||
@ -277,14 +271,11 @@ class StockTransfer extends CommonObject
|
||||
$object->status = self::STATUS_DRAFT;
|
||||
// ...
|
||||
// Clear extrafields that are unique
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0)
|
||||
{
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0) {
|
||||
$extrafields->fetch_name_optionals_label($this->table_element);
|
||||
foreach ($object->array_options as $key => $option)
|
||||
{
|
||||
foreach ($object->array_options as $key => $option) {
|
||||
$shortkey = preg_replace('/options_/', '', $key);
|
||||
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey]))
|
||||
{
|
||||
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
|
||||
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
|
||||
unset($object->array_options[$key]);
|
||||
}
|
||||
@ -300,20 +291,16 @@ class StockTransfer extends CommonObject
|
||||
$this->errors = $object->errors;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// copy internal contacts
|
||||
if ($this->copy_linked_contact($object, 'internal') < 0)
|
||||
{
|
||||
if ($this->copy_linked_contact($object, 'internal') < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// copy external contacts if same company
|
||||
if (property_exists($this, 'socid') && $this->socid == $object->socid)
|
||||
{
|
||||
if (property_exists($this, 'socid') && $this->socid == $object->socid) {
|
||||
if ($this->copy_linked_contact($object, 'external') < 0)
|
||||
$error++;
|
||||
}
|
||||
@ -368,17 +355,17 @@ class StockTransfer extends CommonObject
|
||||
return ($a->rang < $b->rang) ? -1 : 1;
|
||||
}
|
||||
|
||||
function getValorisationTotale() {
|
||||
function getValorisationTotale()
|
||||
{
|
||||
|
||||
$total_pmp = 0;
|
||||
|
||||
if(empty($this->lines)) $this->fetchLines();
|
||||
if(!empty($this->lines)) {
|
||||
if (empty($this->lines)) $this->fetchLines();
|
||||
if (!empty($this->lines)) {
|
||||
foreach ($this->lines as $l) $total_pmp+= ($l->pmp * $l->qty);
|
||||
}
|
||||
|
||||
return $total_pmp;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -411,14 +398,11 @@ class StockTransfer extends CommonObject
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key == 't.rowid') {
|
||||
$sqlwhere[] = $key.'='.$value;
|
||||
}
|
||||
elseif (strpos($key, 'date') !== false) {
|
||||
} elseif (strpos($key, 'date') !== false) {
|
||||
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
|
||||
}
|
||||
elseif ($key == 'customsql') {
|
||||
} elseif ($key == 'customsql') {
|
||||
$sqlwhere[] = $value;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
|
||||
}
|
||||
}
|
||||
@ -438,8 +422,7 @@ class StockTransfer extends CommonObject
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < ($limit ? min($limit, $num) : $num))
|
||||
{
|
||||
while ($i < ($limit ? min($limit, $num) : $num)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$record = new self($this->db);
|
||||
@ -484,8 +467,8 @@ class StockTransfer extends CommonObject
|
||||
*/
|
||||
public function delete(User $user, $notrigger = false)
|
||||
{
|
||||
if(empty($this->lines)) $this->fetchLines();
|
||||
if(!empty($this->lines)) {
|
||||
if (empty($this->lines)) $this->fetchLines();
|
||||
if (!empty($this->lines)) {
|
||||
foreach ($this->lines as $l) $res = $this->deleteLine($user, $l->id);
|
||||
}
|
||||
return $this->deleteCommon($user, $notrigger);
|
||||
@ -503,8 +486,7 @@ class StockTransfer extends CommonObject
|
||||
public function deleteLine(User $user, $idline, $notrigger = false)
|
||||
{
|
||||
global $db;
|
||||
if ($this->status < 0)
|
||||
{
|
||||
if ($this->status < 0) {
|
||||
$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
|
||||
return -2;
|
||||
}
|
||||
@ -531,8 +513,7 @@ class StockTransfer extends CommonObject
|
||||
$error = 0;
|
||||
|
||||
// Protection
|
||||
if ($this->status == self::STATUS_VALIDATED)
|
||||
{
|
||||
if ($this->status == self::STATUS_VALIDATED) {
|
||||
dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
@ -550,12 +531,9 @@ class StockTransfer extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
// Define new ref
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
|
||||
{
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
|
||||
$num = $this->getNextNumRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$num = $this->ref;
|
||||
}
|
||||
$this->newref = $num;
|
||||
@ -571,15 +549,13 @@ class StockTransfer extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($this->db);
|
||||
$this->error = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('STOCKTRANSFER_VALIDATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
@ -587,13 +563,11 @@ class StockTransfer extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->oldref = $this->ref;
|
||||
|
||||
// Rename directory if dir was a temporary ref
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref))
|
||||
{
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
|
||||
// Now we rename also files into index
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'stocktransfer/".$this->db->escape($this->newref)."'";
|
||||
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'stocktransfer/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
|
||||
@ -605,17 +579,14 @@ class StockTransfer extends CommonObject
|
||||
$newref = dol_sanitizeFileName($num);
|
||||
$dirsource = $conf->stocktransfer->dir_output.'/stocktransfer/'.$oldref;
|
||||
$dirdest = $conf->stocktransfer->dir_output.'/stocktransfer/'.$newref;
|
||||
if (!$error && file_exists($dirsource))
|
||||
{
|
||||
if (!$error && file_exists($dirsource)) {
|
||||
dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
if (@rename($dirsource, $dirdest)) {
|
||||
dol_syslog("Rename ok");
|
||||
// Rename docs starting with $oldref with $newref
|
||||
$listoffiles = dol_dir_list($conf->stocktransfer->dir_output.'/stocktransfer/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
|
||||
foreach ($listoffiles as $fileentry)
|
||||
{
|
||||
foreach ($listoffiles as $fileentry) {
|
||||
$dirsource = $fileentry['name'];
|
||||
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
|
||||
$dirsource = $fileentry['path'].'/'.$dirsource;
|
||||
@ -628,19 +599,15 @@ class StockTransfer extends CommonObject
|
||||
}
|
||||
|
||||
// Set new ref and current status
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->ref = $num;
|
||||
$this->status = self::STATUS_VALIDATED;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -657,8 +624,7 @@ class StockTransfer extends CommonObject
|
||||
public function setDraft($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status <= self::STATUS_DRAFT)
|
||||
{
|
||||
if ($this->status <= self::STATUS_DRAFT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -682,8 +648,7 @@ class StockTransfer extends CommonObject
|
||||
public function cancel($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_VALIDATED)
|
||||
{
|
||||
if ($this->status != self::STATUS_VALIDATED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -707,8 +672,7 @@ class StockTransfer extends CommonObject
|
||||
public function reopen($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_CLOSED)
|
||||
{
|
||||
if ($this->status != self::STATUS_CLOSED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -749,8 +713,7 @@ class StockTransfer extends CommonObject
|
||||
|
||||
$url = dol_buildpath('/product/stock/stocktransfer/stocktransfer_card.php', 1).'?id='.$this->id;
|
||||
|
||||
if ($option != 'nolink')
|
||||
{
|
||||
if ($option != 'nolink') {
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
@ -758,17 +721,14 @@ class StockTransfer extends CommonObject
|
||||
}
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowStockTransfer");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
}
|
||||
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart .= $linkclose.'>';
|
||||
@ -792,14 +752,12 @@ class StockTransfer extends CommonObject
|
||||
$pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
|
||||
if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
|
||||
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
|
||||
}
|
||||
|
||||
$result .= '</div>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
}
|
||||
@ -842,8 +800,7 @@ class StockTransfer extends CommonObject
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("stocktransfer@stocktransfer");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
|
||||
@ -876,28 +833,23 @@ class StockTransfer extends CommonObject
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
$sql .= ' WHERE t.rowid = '.$id;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_valid)
|
||||
{
|
||||
if ($obj->fk_user_valid) {
|
||||
$vuser = new User($this->db);
|
||||
$vuser->fetch($obj->fk_user_valid);
|
||||
$this->user_validation = $vuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_cloture)
|
||||
{
|
||||
if ($obj->fk_user_cloture) {
|
||||
$cluser = new User($this->db);
|
||||
$cluser->fetch($obj->fk_user_cloture);
|
||||
$this->user_cloture = $cluser;
|
||||
@ -909,9 +861,7 @@ class StockTransfer extends CommonObject
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
@ -939,14 +889,11 @@ class StockTransfer extends CommonObject
|
||||
$objectline = new StockTransferLine($this->db);
|
||||
$result = $objectline->fetchAll('ASC', 'rang', 0, 0, array('customsql'=>'fk_stocktransfer = '.$this->id));
|
||||
|
||||
if (is_numeric($result))
|
||||
{
|
||||
if (is_numeric($result)) {
|
||||
$this->error = $this->error;
|
||||
$this->errors = $this->errors;
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->lines = $result;
|
||||
return $this->lines;
|
||||
}
|
||||
@ -966,8 +913,7 @@ class StockTransfer extends CommonObject
|
||||
$conf->global->STOCKTRANSFER_STOCKTRANSFER_ADDON = 'mod_stocktransfer_standard';
|
||||
}
|
||||
|
||||
if (!empty($conf->global->STOCKTRANSFER_STOCKTRANSFER_ADDON))
|
||||
{
|
||||
if (!empty($conf->global->STOCKTRANSFER_STOCKTRANSFER_ADDON)) {
|
||||
$mybool = false;
|
||||
|
||||
$file = $conf->global->STOCKTRANSFER_STOCKTRANSFER_ADDON.".php";
|
||||
@ -975,16 +921,14 @@ class StockTransfer extends CommonObject
|
||||
|
||||
// Include file with class
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$dir = dol_buildpath($reldir."core/modules/stocktransfer/");
|
||||
|
||||
// Load file with numbering class (if found)
|
||||
$mybool |= @include_once $dir.$file;
|
||||
}
|
||||
|
||||
if ($mybool === false)
|
||||
{
|
||||
if ($mybool === false) {
|
||||
dol_print_error('', "Failed to include file ".$file);
|
||||
return '';
|
||||
}
|
||||
@ -993,12 +937,9 @@ class StockTransfer extends CommonObject
|
||||
$obj = new $classname();
|
||||
$numref = $obj->getNextValue($this);
|
||||
|
||||
if ($numref != '' && $numref != '-1')
|
||||
{
|
||||
if ($numref != '' && $numref != '-1') {
|
||||
return $numref;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->error = $obj->error;
|
||||
//dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
|
||||
return "";
|
||||
@ -1007,9 +948,7 @@ class StockTransfer extends CommonObject
|
||||
print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -174,23 +174,17 @@ class StockTransferLine extends CommonObject
|
||||
}*/
|
||||
|
||||
// Unset fields that are disabled
|
||||
foreach ($this->fields as $key => $val)
|
||||
{
|
||||
if (isset($val['enabled']) && empty($val['enabled']))
|
||||
{
|
||||
foreach ($this->fields as $key => $val) {
|
||||
if (isset($val['enabled']) && empty($val['enabled'])) {
|
||||
unset($this->fields[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Translate some data of arrayofkeyval
|
||||
if (is_object($langs))
|
||||
{
|
||||
foreach ($this->fields as $key => $val)
|
||||
{
|
||||
if (is_array($val['arrayofkeyval']))
|
||||
{
|
||||
foreach ($val['arrayofkeyval'] as $key2 => $val2)
|
||||
{
|
||||
if (is_object($langs)) {
|
||||
foreach ($this->fields as $key => $val) {
|
||||
if (is_array($val['arrayofkeyval'])) {
|
||||
foreach ($val['arrayofkeyval'] as $key2 => $val2) {
|
||||
$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
|
||||
}
|
||||
}
|
||||
@ -248,14 +242,11 @@ class StockTransferLine extends CommonObject
|
||||
$object->status = self::STATUS_DRAFT;
|
||||
// ...
|
||||
// Clear extrafields that are unique
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0)
|
||||
{
|
||||
if (is_array($object->array_options) && count($object->array_options) > 0) {
|
||||
$extrafields->fetch_name_optionals_label($this->table_element);
|
||||
foreach ($object->array_options as $key => $option)
|
||||
{
|
||||
foreach ($object->array_options as $key => $option) {
|
||||
$shortkey = preg_replace('/options_/', '', $key);
|
||||
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey]))
|
||||
{
|
||||
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
|
||||
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
|
||||
unset($object->array_options[$key]);
|
||||
}
|
||||
@ -271,20 +262,16 @@ class StockTransferLine extends CommonObject
|
||||
$this->errors = $object->errors;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// copy internal contacts
|
||||
if ($this->copy_linked_contact($object, 'internal') < 0)
|
||||
{
|
||||
if ($this->copy_linked_contact($object, 'internal') < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// copy external contacts if same company
|
||||
if (property_exists($this, 'socid') && $this->socid == $object->socid)
|
||||
{
|
||||
if (property_exists($this, 'socid') && $this->socid == $object->socid) {
|
||||
if ($this->copy_linked_contact($object, 'external') < 0)
|
||||
$error++;
|
||||
}
|
||||
@ -360,14 +347,11 @@ class StockTransferLine extends CommonObject
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key == 't.rowid') {
|
||||
$sqlwhere[] = $key.'='.$value;
|
||||
}
|
||||
elseif (strpos($key, 'date') !== false) {
|
||||
} elseif (strpos($key, 'date') !== false) {
|
||||
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
|
||||
}
|
||||
elseif ($key == 'customsql') {
|
||||
} elseif ($key == 'customsql') {
|
||||
$sqlwhere[] = $value;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
|
||||
}
|
||||
}
|
||||
@ -387,8 +371,7 @@ class StockTransferLine extends CommonObject
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < ($limit ? min($limit, $num) : $num))
|
||||
{
|
||||
while ($i < ($limit ? min($limit, $num) : $num)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$record = new self($this->db);
|
||||
@ -444,8 +427,7 @@ class StockTransferLine extends CommonObject
|
||||
*/
|
||||
public function deleteLine(User $user, $idline, $notrigger = false)
|
||||
{
|
||||
if ($this->status < 0)
|
||||
{
|
||||
if ($this->status < 0) {
|
||||
$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
|
||||
return -2;
|
||||
}
|
||||
@ -453,7 +435,8 @@ class StockTransferLine extends CommonObject
|
||||
return $this->deleteLineCommon($user, $idline, $notrigger);
|
||||
}
|
||||
|
||||
function doStockMovement($label, $fk_entrepot, $direction=1) {
|
||||
function doStockMovement($label, $fk_entrepot, $direction = 1)
|
||||
{
|
||||
|
||||
global $db, $conf, $user, $langs;
|
||||
|
||||
@ -469,8 +452,7 @@ class StockTransferLine extends CommonObject
|
||||
$movementstock->origin = new StockTransfer($db);
|
||||
$movementstock->origin->id = $this->fk_stocktransfer;
|
||||
|
||||
if (empty($this->batch)) // no batch for line
|
||||
{
|
||||
if (empty($this->batch)) { // no batch for line
|
||||
/*$result = $p->correct_stock(
|
||||
$user,
|
||||
$fk_entrepot,
|
||||
@ -489,8 +471,7 @@ class StockTransferLine extends CommonObject
|
||||
setEventMessages($p->errors, $p->errorss, 'errors');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($p->hasbatch()) {
|
||||
$arraybatchinfo = $p->loadBatchInfo($this->batch);
|
||||
if (count($arraybatchinfo) > 0) {
|
||||
@ -529,7 +510,6 @@ class StockTransferLine extends CommonObject
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -548,8 +528,7 @@ class StockTransferLine extends CommonObject
|
||||
$error = 0;
|
||||
|
||||
// Protection
|
||||
if ($this->status == self::STATUS_VALIDATED)
|
||||
{
|
||||
if ($this->status == self::STATUS_VALIDATED) {
|
||||
dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
@ -567,12 +546,9 @@ class StockTransferLine extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
// Define new ref
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
|
||||
{
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
|
||||
$num = $this->getNextNumRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$num = $this->ref;
|
||||
}
|
||||
$this->newref = $num;
|
||||
@ -588,15 +564,13 @@ class StockTransferLine extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($this->db);
|
||||
$this->error = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('STOCKTRANSFERLINE_VALIDATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
@ -604,13 +578,11 @@ class StockTransferLine extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->oldref = $this->ref;
|
||||
|
||||
// Rename directory if dir was a temporary ref
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref))
|
||||
{
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
|
||||
// Now we rename also files into index
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'stocktransferline/".$this->db->escape($this->newref)."'";
|
||||
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'stocktransferline/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
|
||||
@ -622,17 +594,14 @@ class StockTransferLine extends CommonObject
|
||||
$newref = dol_sanitizeFileName($num);
|
||||
$dirsource = $conf->stocktransfer->dir_output.'/stocktransferline/'.$oldref;
|
||||
$dirdest = $conf->stocktransfer->dir_output.'/stocktransferline/'.$newref;
|
||||
if (!$error && file_exists($dirsource))
|
||||
{
|
||||
if (!$error && file_exists($dirsource)) {
|
||||
dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
if (@rename($dirsource, $dirdest)) {
|
||||
dol_syslog("Rename ok");
|
||||
// Rename docs starting with $oldref with $newref
|
||||
$listoffiles = dol_dir_list($conf->stocktransfer->dir_output.'/stocktransferline/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
|
||||
foreach ($listoffiles as $fileentry)
|
||||
{
|
||||
foreach ($listoffiles as $fileentry) {
|
||||
$dirsource = $fileentry['name'];
|
||||
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
|
||||
$dirsource = $fileentry['path'].'/'.$dirsource;
|
||||
@ -645,19 +614,15 @@ class StockTransferLine extends CommonObject
|
||||
}
|
||||
|
||||
// Set new ref and current status
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->ref = $num;
|
||||
$this->status = self::STATUS_VALIDATED;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -674,8 +639,7 @@ class StockTransferLine extends CommonObject
|
||||
public function setDraft($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status <= self::STATUS_DRAFT)
|
||||
{
|
||||
if ($this->status <= self::STATUS_DRAFT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -699,8 +663,7 @@ class StockTransferLine extends CommonObject
|
||||
public function cancel($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_VALIDATED)
|
||||
{
|
||||
if ($this->status != self::STATUS_VALIDATED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -724,8 +687,7 @@ class StockTransferLine extends CommonObject
|
||||
public function reopen($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_CANCELED)
|
||||
{
|
||||
if ($this->status != self::STATUS_CANCELED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -766,8 +728,7 @@ class StockTransferLine extends CommonObject
|
||||
|
||||
$url = dol_buildpath('/stocktransfer/stocktransferline_card.php', 1).'?id='.$this->id;
|
||||
|
||||
if ($option != 'nolink')
|
||||
{
|
||||
if ($option != 'nolink') {
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
@ -775,17 +736,14 @@ class StockTransferLine extends CommonObject
|
||||
}
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowStockTransferLine");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
}
|
||||
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart .= $linkclose.'>';
|
||||
@ -809,14 +767,12 @@ class StockTransferLine extends CommonObject
|
||||
$pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
|
||||
if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
|
||||
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
|
||||
}
|
||||
|
||||
$result .= '</div>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
}
|
||||
@ -859,8 +815,7 @@ class StockTransferLine extends CommonObject
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("stocktransfer@stocktransfer");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
|
||||
@ -891,28 +846,23 @@ class StockTransferLine extends CommonObject
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
$sql .= ' WHERE t.rowid = '.$id;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_valid)
|
||||
{
|
||||
if ($obj->fk_user_valid) {
|
||||
$vuser = new User($this->db);
|
||||
$vuser->fetch($obj->fk_user_valid);
|
||||
$this->user_validation = $vuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_cloture)
|
||||
{
|
||||
if ($obj->fk_user_cloture) {
|
||||
$cluser = new User($this->db);
|
||||
$cluser->fetch($obj->fk_user_cloture);
|
||||
$this->user_cloture = $cluser;
|
||||
@ -924,9 +874,7 @@ class StockTransferLine extends CommonObject
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
@ -954,14 +902,11 @@ class StockTransferLine extends CommonObject
|
||||
$objectline = new StockTransferLineLine($this->db);
|
||||
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_stocktransferline = '.$this->id));
|
||||
|
||||
if (is_numeric($result))
|
||||
{
|
||||
if (is_numeric($result)) {
|
||||
$this->error = $this->error;
|
||||
$this->errors = $this->errors;
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->lines = $result;
|
||||
return $this->lines;
|
||||
}
|
||||
@ -981,8 +926,7 @@ class StockTransferLine extends CommonObject
|
||||
$conf->global->STOCKTRANSFER_STOCKTRANSFERLINE_ADDON = 'mod_stocktransferline_standard';
|
||||
}
|
||||
|
||||
if (!empty($conf->global->STOCKTRANSFER_STOCKTRANSFERLINE_ADDON))
|
||||
{
|
||||
if (!empty($conf->global->STOCKTRANSFER_STOCKTRANSFERLINE_ADDON)) {
|
||||
$mybool = false;
|
||||
|
||||
$file = $conf->global->STOCKTRANSFER_STOCKTRANSFERLINE_ADDON.".php";
|
||||
@ -990,16 +934,14 @@ class StockTransferLine extends CommonObject
|
||||
|
||||
// Include file with class
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$dir = dol_buildpath($reldir."core/modules/stocktransfer/");
|
||||
|
||||
// Load file with numbering class (if found)
|
||||
$mybool |= @include_once $dir.$file;
|
||||
}
|
||||
|
||||
if ($mybool === false)
|
||||
{
|
||||
if ($mybool === false) {
|
||||
dol_print_error('', "Failed to include file ".$file);
|
||||
return '';
|
||||
}
|
||||
@ -1008,12 +950,9 @@ class StockTransferLine extends CommonObject
|
||||
$obj = new $classname();
|
||||
$numref = $obj->getNextValue($this);
|
||||
|
||||
if ($numref != '' && $numref != '-1')
|
||||
{
|
||||
if ($numref != '' && $numref != '-1') {
|
||||
return $numref;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->error = $obj->error;
|
||||
//dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
|
||||
return "";
|
||||
@ -1022,9 +961,7 @@ class StockTransferLine extends CommonObject
|
||||
print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -42,8 +42,7 @@ function stocktransferPrepareHead($object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = dol_buildpath('/product/stock/stocktransfer/stocktransfer_contact.php', 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
@ -52,8 +51,7 @@ function stocktransferPrepareHead($object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
|
||||
{
|
||||
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
|
||||
$nbNote = 0;
|
||||
if (!empty($object->note_private)) $nbNote++;
|
||||
if (!empty($object->note_public)) $nbNote++;
|
||||
|
||||
@ -55,13 +55,10 @@ $action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
if (GETPOST('actioncode', 'array'))
|
||||
{
|
||||
if (GETPOST('actioncode', 'array')) {
|
||||
$actioncode = GETPOST('actioncode', 'array', 3);
|
||||
if (!count($actioncode)) $actioncode = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||
}
|
||||
$search_agenda_label = GETPOST('search_agenda_label');
|
||||
@ -105,18 +102,15 @@ $parameters = array('id'=>$id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
|
||||
{
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$actioncode = '';
|
||||
$search_agenda_label = '';
|
||||
}
|
||||
@ -130,8 +124,7 @@ if (empty($reshook))
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($object->id > 0)
|
||||
{
|
||||
if ($object->id > 0) {
|
||||
$title = $langs->trans("Agenda");
|
||||
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
|
||||
$help_url = '';
|
||||
@ -209,8 +202,7 @@ if ($object->id > 0)
|
||||
|
||||
$out = '&origin='.$object->element.'&originid='.$object->id;
|
||||
$permok = $user->rights->agenda->myactions->create;
|
||||
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
|
||||
{
|
||||
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
|
||||
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
|
||||
if (get_class($objthirdparty) == 'Societe') $out .= '&socid='.$objthirdparty->id;
|
||||
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1';
|
||||
@ -222,22 +214,17 @@ if ($object->id > 0)
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (!empty($conf->agenda->enabled))
|
||||
{
|
||||
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
|
||||
{
|
||||
if (!empty($conf->agenda->enabled)) {
|
||||
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
|
||||
{
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
|
||||
$param = '&id='.$object->id.'&socid='.$socid;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
|
||||
@ -101,8 +101,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
|
||||
// Initialize array of search criterias
|
||||
$search_all = trim(GETPOST("search_all", 'alpha'));
|
||||
$search = array();
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||
}
|
||||
|
||||
@ -140,8 +139,7 @@ $parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
$error = 0;
|
||||
|
||||
$backurlforlist = dol_buildpath('/product/stock/stocktransfer/stocktransfer_list.php', 1);
|
||||
@ -169,30 +167,27 @@ if (empty($reshook))
|
||||
// Action to build doc
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
if ($action == 'set_thirdparty' && $permissiontoadd)
|
||||
{
|
||||
if ($action == 'set_thirdparty' && $permissiontoadd) {
|
||||
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'STOCKTRANSFER_MODIFY');
|
||||
}
|
||||
if ($action == 'classin' && $permissiontoadd)
|
||||
{
|
||||
if ($action == 'classin' && $permissiontoadd) {
|
||||
$object->setProject(GETPOST('projectid', 'int'));
|
||||
}
|
||||
|
||||
if($action == 'addline' && $permissiontoadd) {
|
||||
|
||||
if($qty <= 0) {
|
||||
if ($action == 'addline' && $permissiontoadd) {
|
||||
if ($qty <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
|
||||
$action = 'view';
|
||||
}
|
||||
|
||||
if($fk_warehouse_source <= 0) {
|
||||
if ($fk_warehouse_source <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors');
|
||||
$action = 'view';
|
||||
}
|
||||
|
||||
if($fk_warehouse_destination <= 0) {
|
||||
if ($fk_warehouse_destination <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors');
|
||||
$action = 'view';
|
||||
@ -200,25 +195,23 @@ if (empty($reshook))
|
||||
|
||||
$prod = new Product($db);
|
||||
$prod->fetch($fk_product);
|
||||
if ($prod->hasbatch())
|
||||
{
|
||||
if (empty($batch))
|
||||
{
|
||||
if ($prod->hasbatch()) {
|
||||
if (empty($batch)) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors');
|
||||
}
|
||||
} else {
|
||||
if(!empty($batch)) {
|
||||
if (!empty($batch)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($error)) {
|
||||
if (empty($error)) {
|
||||
$line = new StockTransferLine($db);
|
||||
$records = $line->fetchAll('', '', 0, 0, array('customsql'=>' fk_stocktransfer = '.$id.' AND fk_product = '.$fk_product.' AND fk_warehouse_source = '.$fk_warehouse_source.' AND fk_warehouse_destination = '.$fk_warehouse_destination.' AND ('.(empty($batch) ? 'batch = "" or batch IS NULL' : 'batch = "'.$batch.'"' ).')'));
|
||||
if(!empty($records[key($records)])) $line = $records[key($records)];
|
||||
if (!empty($records[key($records)])) $line = $records[key($records)];
|
||||
$line->fk_stocktransfer = $id;
|
||||
$line->qty += $qty;
|
||||
$line->fk_warehouse_source = $fk_warehouse_source;
|
||||
@ -227,28 +220,27 @@ if (empty($reshook))
|
||||
$line->batch = $batch;
|
||||
|
||||
$line->pmp = $prod->pmp;
|
||||
if($line->id > 0) $line->update($user);
|
||||
if ($line->id > 0) $line->update($user);
|
||||
else {
|
||||
$line->rang = count($object->lines) + 1;
|
||||
$line->create($user);
|
||||
}
|
||||
$object->fetchLines();
|
||||
}
|
||||
} elseif($action === 'updateline' && $permissiontoadd) {
|
||||
|
||||
if($qty <= 0) {
|
||||
} elseif ($action === 'updateline' && $permissiontoadd) {
|
||||
if ($qty <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
|
||||
$action = 'editline';
|
||||
}
|
||||
|
||||
if($fk_warehouse_source <= 0) {
|
||||
if ($fk_warehouse_source <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors');
|
||||
$action = 'editline';
|
||||
}
|
||||
|
||||
if($fk_warehouse_destination <= 0) {
|
||||
if ($fk_warehouse_destination <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors');
|
||||
$action = 'editline';
|
||||
@ -256,24 +248,22 @@ if (empty($reshook))
|
||||
|
||||
$prod = new Product($db);
|
||||
$prod->fetch($fk_product);
|
||||
if ($prod->hasbatch())
|
||||
{
|
||||
if (empty($batch))
|
||||
{
|
||||
if ($prod->hasbatch()) {
|
||||
if (empty($batch)) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors');
|
||||
$action = 'editline';
|
||||
}
|
||||
} else {
|
||||
if(!empty($batch)) {
|
||||
if (!empty($batch)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
|
||||
$action = 'editline';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($error)) {
|
||||
if (empty($error)) {
|
||||
$line = new StockTransferLine($db);
|
||||
$line->fetch($lineid);
|
||||
$line->qty = $qty;
|
||||
@ -287,18 +277,18 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Décrémentation
|
||||
if($action == 'confirm_destock' && $confirm == 'yes' && $object->status == $object::STATUS_VALIDATED) {
|
||||
if ($action == 'confirm_destock' && $confirm == 'yes' && $object->status == $object::STATUS_VALIDATED) {
|
||||
$lines = $object->getLinesArray();
|
||||
if(!empty($lines)) {
|
||||
if (!empty($lines)) {
|
||||
$db->begin();
|
||||
foreach ($lines as $line) {
|
||||
$res = $line->doStockMovement($label, $line->fk_warehouse_source);
|
||||
if($res <= 0) $error++;
|
||||
if ($res <= 0) $error++;
|
||||
}
|
||||
if(empty($error)) $db->commit();
|
||||
if (empty($error)) $db->commit();
|
||||
else $db->rollback();
|
||||
}
|
||||
if(empty($error)) {
|
||||
if (empty($error)) {
|
||||
$object->setStatut($object::STATUS_TRANSFERED, $id);
|
||||
$object->status = $object::STATUS_TRANSFERED;
|
||||
$object->date_reelle_depart = date('Y-m-d');
|
||||
@ -308,18 +298,18 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Annulation décrémentation
|
||||
if($action == 'confirm_destockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
|
||||
if ($action == 'confirm_destockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
|
||||
$lines = $object->getLinesArray();
|
||||
if(!empty($lines)) {
|
||||
if (!empty($lines)) {
|
||||
$db->begin();
|
||||
foreach ($lines as $line) {
|
||||
$res = $line->doStockMovement($label, $line->fk_warehouse_source, 0);
|
||||
if($res <= 0) $error++;
|
||||
if ($res <= 0) $error++;
|
||||
}
|
||||
if(empty($error)) $db->commit();
|
||||
if (empty($error)) $db->commit();
|
||||
else $db->rollback();
|
||||
}
|
||||
if(empty($error)) {
|
||||
if (empty($error)) {
|
||||
$object->setStatut($object::STATUS_VALIDATED, $id);
|
||||
$object->status = $object::STATUS_VALIDATED;
|
||||
$object->date_reelle_depart = null;
|
||||
@ -329,18 +319,18 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Incrémentation
|
||||
if($action == 'confirm_addstock' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
|
||||
if ($action == 'confirm_addstock' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
|
||||
$lines = $object->getLinesArray();
|
||||
if(!empty($lines)) {
|
||||
if (!empty($lines)) {
|
||||
$db->begin();
|
||||
foreach ($lines as $line) {
|
||||
$res = $line->doStockMovement($label, $line->fk_warehouse_destination, 0);
|
||||
if($res <= 0) $error++;
|
||||
if ($res <= 0) $error++;
|
||||
}
|
||||
if(empty($error)) $db->commit();
|
||||
if (empty($error)) $db->commit();
|
||||
else $db->rollback();
|
||||
}
|
||||
if(empty($error)) {
|
||||
if (empty($error)) {
|
||||
$object->setStatut($object::STATUS_CLOSED, $id);
|
||||
$object->status = $object::STATUS_CLOSED;
|
||||
$object->date_reelle_arrivee = date('Y-m-d');
|
||||
@ -350,18 +340,18 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Annulation incrémentation
|
||||
if($action == 'confirm_addstockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_CLOSED) {
|
||||
if ($action == 'confirm_addstockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_CLOSED) {
|
||||
$lines = $object->getLinesArray();
|
||||
if(!empty($lines)) {
|
||||
if (!empty($lines)) {
|
||||
$db->begin();
|
||||
foreach ($lines as $line) {
|
||||
$res = $line->doStockMovement($label, $line->fk_warehouse_destination);
|
||||
if($res <= 0) $error++;
|
||||
if ($res <= 0) $error++;
|
||||
}
|
||||
if(empty($error)) $db->commit();
|
||||
if (empty($error)) $db->commit();
|
||||
else $db->rollback();
|
||||
}
|
||||
if(empty($error)) {
|
||||
if (empty($error)) {
|
||||
$object->setStatut($object::STATUS_TRANSFERED, $id);
|
||||
$object->status = $object::STATUS_TRANSFERED;
|
||||
$object->date_reelle_arrivee = null;
|
||||
@ -399,8 +389,8 @@ jQuery(document).ready(function() {';
|
||||
// Affichage alerte date prévue de départ si transfert concerné
|
||||
$date_prevue_depart = $object->date_prevue_depart;
|
||||
$date_prevue_depart_plus_delai = $date_prevue_depart;
|
||||
if($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day');
|
||||
if(!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) {
|
||||
if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day');
|
||||
if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) {
|
||||
print "$('.valuefield.fieldname_date_prevue_depart').append('";
|
||||
print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
|
||||
print "');";
|
||||
@ -411,8 +401,7 @@ print '});
|
||||
|
||||
|
||||
// Part to create
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("StockTransfer")), '', 'object_'.$object->picto);
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -450,8 +439,7 @@ if ($action == 'create')
|
||||
}
|
||||
|
||||
// Part to edit record
|
||||
if (($id || $ref) && $action == 'edit')
|
||||
{
|
||||
if (($id || $ref) && $action == 'edit') {
|
||||
//if($object->status < 3) {
|
||||
print load_fiche_titre($langs->trans("StockTransfer"), '', 'object_' . $object->picto);
|
||||
|
||||
@ -485,8 +473,7 @@ if (($id || $ref) && $action == 'edit')
|
||||
}
|
||||
|
||||
// Part to show record
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
|
||||
{
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
|
||||
$res = $object->fetch_optionals();
|
||||
|
||||
$head = stocktransferPrepareHead($object);
|
||||
@ -495,13 +482,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$formconfirm = '';
|
||||
|
||||
// Confirmation to delete
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteStockTransfer'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
|
||||
}
|
||||
// Confirmation to delete line
|
||||
if ($action == 'deleteline')
|
||||
{
|
||||
if ($action == 'deleteline') {
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
|
||||
}
|
||||
// Clone confirmation
|
||||
@ -540,8 +525,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}
|
||||
|
||||
// Confirmation of action xxxx
|
||||
if ($action == 'xxx')
|
||||
{
|
||||
if ($action == 'xxx') {
|
||||
$formquestion = array();
|
||||
/*
|
||||
$forcecombo=0;
|
||||
@ -649,8 +633,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
* Lines
|
||||
*/
|
||||
|
||||
if (!empty($object->table_element_line))
|
||||
{
|
||||
if (!empty($object->table_element_line)) {
|
||||
// Show object lines
|
||||
/*$result = $object->getLinesArray();
|
||||
|
||||
@ -707,9 +690,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
<input type="hidden" name="mode" value="">
|
||||
<input type="hidden" name="id" value="' . $object->id.'">
|
||||
';
|
||||
if($lineid > 0) print '<input type="hidden" name="lineid" value="'.$lineid.'" />';
|
||||
if ($lineid > 0) print '<input type="hidden" name="lineid" value="'.$lineid.'" />';
|
||||
print '<table id="tablelines" class="liste centpercent">';
|
||||
//print '<div class="tagtable centpercent">';
|
||||
//print '<div class="tagtable centpercent">';
|
||||
|
||||
$param = '';
|
||||
|
||||
@ -723,7 +706,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone ');
|
||||
print getTitleFieldOfList($langs->trans('AverageUnitPricePMPShort'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone ');
|
||||
print getTitleFieldOfList($langs->trans('PMPValue'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone ');
|
||||
if(empty($object->status)) {
|
||||
if (empty($object->status)) {
|
||||
print getTitleFieldOfList('', 0);
|
||||
print getTitleFieldOfList('', 0);
|
||||
print getTitleFieldOfList('', 0);
|
||||
@ -736,8 +719,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$warehousestatics = new Entrepot($db);
|
||||
$warehousestatict = new Entrepot($db);
|
||||
|
||||
foreach ($listofdata as $key => $line)
|
||||
{
|
||||
foreach ($listofdata as $key => $line) {
|
||||
$productstatic->fetch($line->fk_product);
|
||||
$warehousestatics->fetch($line->fk_warehouse_source);
|
||||
$warehousestatict->fetch($line->fk_warehouse_destination);
|
||||
@ -750,25 +732,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
print '<tr id="row-'.$line->id.'" class="drag drop oddeven" '.$domData.'>';
|
||||
print '<td class="titlefield">';
|
||||
if($action === 'editline' && $line->id == $lineid) $form->select_produits($line->fk_product, 'fk_product', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1);
|
||||
if ($action === 'editline' && $line->id == $lineid) $form->select_produits($line->fk_product, 'fk_product', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1);
|
||||
else print $productstatic->getNomUrl(1).' - '.$productstatic->label;
|
||||
print '</td>';
|
||||
if ($conf->productbatch->enabled)
|
||||
{
|
||||
if ($conf->productbatch->enabled) {
|
||||
print '<td>';
|
||||
if($action === 'editline' && $line->id == $lineid) print '<input type="text" value="'.$line->batch.'" name="batch" class="flat maxwidth50"/>';
|
||||
if ($action === 'editline' && $line->id == $lineid) print '<input type="text" value="'.$line->batch.'" name="batch" class="flat maxwidth50"/>';
|
||||
else print $line->batch;
|
||||
print '</td>';
|
||||
}
|
||||
print '<td>';
|
||||
if($action === 'editline' && $line->id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
|
||||
if ($action === 'editline' && $line->id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
|
||||
else print $warehousestatics->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if($action === 'editline' && $line->id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_destination,'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseDestination);
|
||||
if ($action === 'editline' && $line->id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseDestination);
|
||||
else print $warehousestatict->getNomUrl(1);
|
||||
print '</td>';
|
||||
if($action === 'editline' && $line->id == $lineid) print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.'"></td>';
|
||||
if ($action === 'editline' && $line->id == $lineid) print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.'"></td>';
|
||||
else print '<td class="center">'.$line->qty.'</td>';
|
||||
print '<td class="center">';
|
||||
print price($line->pmp, 0, '', 1, -1, -1, $conf->currency);
|
||||
@ -776,9 +757,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<td class="center">';
|
||||
print price($line->pmp * $line->qty, 0, '', 1, -1, -1, $conf->currency);
|
||||
print '</td>';
|
||||
if(empty($object->status)) {
|
||||
|
||||
if($action === 'editline' && $line->id == $lineid) {
|
||||
if (empty($object->status)) {
|
||||
if ($action === 'editline' && $line->id == $lineid) {
|
||||
//print '<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($langs->trans('Save')) . '"></td>';
|
||||
print '<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans("Save").'"><br>';
|
||||
print '<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||
@ -817,9 +797,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if(empty($object->status) && $action !== 'editline') {
|
||||
if (empty($object->status) && $action !== 'editline') {
|
||||
print '<tr class="oddeven">';
|
||||
// Product
|
||||
// Product
|
||||
print '<td class="titlefield">';
|
||||
$filtertype = 0;
|
||||
if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype = '';
|
||||
@ -842,21 +822,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
// On stock ceux qui ne doivent pas être proposés dans la liste
|
||||
$TExcludedWarehouseSource=array();
|
||||
if(!empty($object->fk_warehouse_source)) {
|
||||
if (!empty($object->fk_warehouse_source)) {
|
||||
$source_ent = new Entrepot($db);
|
||||
$source_ent->fetch($object->fk_warehouse_source);
|
||||
foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
|
||||
if(strpos($TDataCacheWarehouse['full_label'], $source_ent->label) === false) $TExcludedWarehouseSource[] = $TDataCacheWarehouse['id'];
|
||||
if (strpos($TDataCacheWarehouse['full_label'], $source_ent->label) === false) $TExcludedWarehouseSource[] = $TDataCacheWarehouse['id'];
|
||||
}
|
||||
}
|
||||
|
||||
// On stock ceux qui ne doivent pas être proposés dans la liste
|
||||
$TExcludedWarehouseDestination=array();
|
||||
if(!empty($object->fk_warehouse_destination)) {
|
||||
if (!empty($object->fk_warehouse_destination)) {
|
||||
$dest_ent = new Entrepot($db);
|
||||
$dest_ent->fetch($object->fk_warehouse_destination);
|
||||
foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
|
||||
if(strpos($TDataCacheWarehouse['full_label'], $dest_ent->label) === false) $TExcludedWarehouseDestination[] = $TDataCacheWarehouse['id'];
|
||||
if (strpos($TDataCacheWarehouse['full_label'], $dest_ent->label) === false) $TExcludedWarehouseDestination[] = $TDataCacheWarehouse['id'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -885,7 +865,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
// Grad and drop lines
|
||||
print '<td></td>';
|
||||
print '</tr>';
|
||||
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
@ -900,25 +879,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$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 (empty($reshook)) {
|
||||
// Send
|
||||
if (empty($user->socid)) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
|
||||
}
|
||||
|
||||
// Back to draft
|
||||
if ($object->status == $object::STATUS_VALIDATED)
|
||||
{
|
||||
if ($permissiontoadd)
|
||||
{
|
||||
if ($object->status == $object::STATUS_VALIDATED) {
|
||||
if ($permissiontoadd) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// Modify
|
||||
if ($permissiontoadd)
|
||||
{
|
||||
if ($permissiontoadd) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
|
||||
}
|
||||
/*else
|
||||
@ -927,38 +902,26 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}*/
|
||||
|
||||
// Validate
|
||||
if ($object->status == $object::STATUS_DRAFT)
|
||||
{
|
||||
if ($permissiontoadd)
|
||||
{
|
||||
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0))
|
||||
{
|
||||
if ($object->status == $object::STATUS_DRAFT) {
|
||||
if ($permissiontoadd) {
|
||||
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elseif($object->status == $object::STATUS_VALIDATED) {
|
||||
} elseif ($object->status == $object::STATUS_VALIDATED) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=destock">'.$langs->trans("StockTransferDecrementation").'</a>';
|
||||
}
|
||||
|
||||
elseif($object->status == $object::STATUS_TRANSFERED) {
|
||||
} elseif ($object->status == $object::STATUS_TRANSFERED) {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=destockcancel">'.$langs->trans("StockTransferDecrementationCancel").'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=addstock">'.$langs->trans("StockTransferIncrementation").'</a>';
|
||||
}
|
||||
|
||||
elseif($object->status == $object::STATUS_CLOSED) {
|
||||
} elseif ($object->status == $object::STATUS_CLOSED) {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=addstockcancel">'.$langs->trans("StockTransferIncrementationCancel").'</a>';
|
||||
}
|
||||
|
||||
// Clone
|
||||
if ($permissiontoadd)
|
||||
{
|
||||
if ($permissiontoadd) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=stocktransfer">'.$langs->trans("ToClone").'</a>'."\n";
|
||||
}
|
||||
|
||||
@ -988,8 +951,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
*/
|
||||
|
||||
// Delete (need delete permission, or if draft, just need create/modify permission)
|
||||
if ($object->status < $object::STATUS_TRANSFERED && $permissiontoadd)
|
||||
{
|
||||
if ($object->status < $object::STATUS_TRANSFERED && $permissiontoadd) {
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a>'."\n";
|
||||
}
|
||||
/*else
|
||||
@ -1006,8 +968,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
if ($action != 'presend')
|
||||
{
|
||||
if ($action != 'presend') {
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
|
||||
@ -52,27 +52,20 @@ $result = restrictedArea($user, 'stocktransfer', $id, '', 'stocktransfer');
|
||||
$object = new StockTransfer($db);
|
||||
|
||||
// Load object
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$ret = $object->fetch($id, $ref);
|
||||
if ($ret == 0)
|
||||
{
|
||||
if ($ret == 0) {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
elseif ($ret < 0)
|
||||
{
|
||||
} elseif ($ret < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$object->fetch_thirdparty();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
header('Location: '.dol_buildpath('/stocktransfer/stocktransfer_list.php', 1));
|
||||
exit;
|
||||
}
|
||||
@ -82,54 +75,40 @@ else
|
||||
* Add a new contact
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->rights->stocktransfer->stocktransfer->write)
|
||||
{
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$result = $object->add_contact($contactid, !empty($_POST["typecontact"]) ? $_POST["typecontact"] : $_POST["type"], $_POST["source"]);
|
||||
}
|
||||
if ($action == 'addcontact' && $user->rights->stocktransfer->stocktransfer->write) {
|
||||
if ($object->id > 0) {
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$result = $object->add_contact($contactid, !empty($_POST["typecontact"]) ? $_POST["typecontact"] : $_POST["type"], $_POST["source"]);
|
||||
}
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle the status of a contact
|
||||
elseif ($action == 'swapstatut' && $user->rights->stocktransfer->stocktransfer->write)
|
||||
{
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$result = $object->swapContactStatus(GETPOST('ligne'));
|
||||
elseif ($action == 'swapstatut' && $user->rights->stocktransfer->stocktransfer->write) {
|
||||
if ($object->id > 0) {
|
||||
$result = $object->swapContactStatus(GETPOST('ligne'));
|
||||
}
|
||||
}
|
||||
|
||||
// Deletes a contact
|
||||
elseif ($action == 'deletecontact' && $user->rights->stocktransfer->stocktransfer->write)
|
||||
{
|
||||
elseif ($action == 'deletecontact' && $user->rights->stocktransfer->stocktransfer->write) {
|
||||
$result = $object->delete_contact($lineid);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
@ -151,9 +130,8 @@ $form = new Form($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
$formother = new FormOther($db);
|
||||
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$head = stocktransferPrepareHead($object);
|
||||
if ($object->id > 0) {
|
||||
$head = stocktransferPrepareHead($object);
|
||||
dol_fiche_head($head, 'contact', $langs->trans("StockTransfer"), -1, 'stock');
|
||||
|
||||
|
||||
@ -167,42 +145,40 @@ if ($object->id > 0)
|
||||
$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
|
||||
$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
if(!empty($object->thirdparty)) {
|
||||
if (!empty($object->thirdparty)) {
|
||||
$morehtmlref .= '<br>' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer');
|
||||
}
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||
if ($user->rights->stocktransfer->stocktransfer->write)
|
||||
{
|
||||
if ($action != 'classify') {
|
||||
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
|
||||
$morehtmlref .= ' : ';
|
||||
}
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref .= '</form>';
|
||||
} 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 .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
|
||||
$morehtmlref .= $proj->ref;
|
||||
$morehtmlref .= '</a>';
|
||||
} else {
|
||||
$morehtmlref .= '';
|
||||
}
|
||||
}
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||
if ($user->rights->stocktransfer->stocktransfer->write) {
|
||||
if ($action != 'classify') {
|
||||
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
|
||||
$morehtmlref .= ' : ';
|
||||
}
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref .= '</form>';
|
||||
} 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 .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
|
||||
$morehtmlref .= $proj->ref;
|
||||
$morehtmlref .= '</a>';
|
||||
} else {
|
||||
$morehtmlref .= '';
|
||||
}
|
||||
}
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
@ -213,8 +189,7 @@ if ($object->id > 0)
|
||||
$user->rights->stocktransfer->write = $user->rights->stocktransfer->stocktransfer->write;
|
||||
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
|
||||
foreach ($dirtpls as $reldir)
|
||||
{
|
||||
foreach ($dirtpls as $reldir) {
|
||||
$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
|
||||
if ($res) break;
|
||||
}
|
||||
|
||||
@ -108,8 +108,7 @@ $help_url = '';
|
||||
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($object->id) {
|
||||
/*
|
||||
* Show tabs
|
||||
*/
|
||||
@ -121,8 +120,7 @@ if ($object->id)
|
||||
// Build file list
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||
$totalsize = 0;
|
||||
foreach ($filearray as $key => $file)
|
||||
{
|
||||
foreach ($filearray as $key => $file) {
|
||||
$totalsize += $file['size'];
|
||||
}
|
||||
|
||||
@ -200,9 +198,7 @@ if ($object->id)
|
||||
$relativepathwithnofile = 'stocktransfer/'.dol_sanitizeFileName($object->ref).'/';
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
accessforbidden('', 0, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -112,31 +112,26 @@ if (!$sortorder) $sortorder = "ASC";
|
||||
// Initialize array of search criterias
|
||||
$search_all = GETPOST('search_all', 'alphanohtml') ? trim(GETPOST('search_all', 'alphanohtml')) : trim(GETPOST('sall', 'alphanohtml'));
|
||||
$search = array();
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||
}
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array();
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
|
||||
}
|
||||
|
||||
// Definition of fields for list
|
||||
$arrayfields = array();
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
foreach ($object->fields as $key => $val) {
|
||||
// If $val['visible']==0, then we never show the field
|
||||
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>(verifCond($val['enabled']) && ($val['visible'] != 3)), 'position'=>$val['position']);
|
||||
}
|
||||
//var_dump($object->fields);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
|
||||
$arrayfields["ef.".$key] = array(
|
||||
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
|
||||
@ -158,8 +153,7 @@ $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete;
|
||||
// Security check
|
||||
if (empty($conf->stocktransfer->enabled)) accessforbidden('Module not enabled');
|
||||
$socid = 0;
|
||||
if ($user->socid > 0) // Protection if external user
|
||||
{
|
||||
if ($user->socid > 0) { // Protection if external user
|
||||
//$socid = $user->socid;
|
||||
accessforbidden();
|
||||
}
|
||||
@ -179,24 +173,20 @@ $parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$search[$key] = '';
|
||||
}
|
||||
$toselect = '';
|
||||
$search_array_options = array();
|
||||
}
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
|
||||
{
|
||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
|
||||
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||
}
|
||||
|
||||
@ -225,8 +215,7 @@ $title = $langs->trans('StockTransferList');
|
||||
// Build and execute select
|
||||
// --------------------------------------------------------------------
|
||||
$sql = 'SELECT ';
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$sql .= 't.'.$key.', ';
|
||||
}
|
||||
// Add fields from extrafields
|
||||
@ -242,8 +231,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
|
||||
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
|
||||
else $sql .= " WHERE 1 = 1";
|
||||
foreach ($search as $key => $val)
|
||||
{
|
||||
foreach ($search as $key => $val) {
|
||||
if ($key == 'status' && $search[$key] == -1) continue;
|
||||
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
|
||||
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
|
||||
@ -282,28 +270,22 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
||||
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
|
||||
{
|
||||
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
|
||||
$num = $nbtotalofrecords;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
@ -312,8 +294,7 @@ else
|
||||
}
|
||||
|
||||
// Direct jump if only one record found
|
||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
|
||||
{
|
||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$id = $obj->rowid;
|
||||
header("Location: ".dol_buildpath('/product/stock/stocktransfer/stocktransfer_card.php', 1).'?id='.$id);
|
||||
@ -346,8 +327,7 @@ $arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
foreach ($search as $key => $val)
|
||||
{
|
||||
foreach ($search as $key => $val) {
|
||||
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
|
||||
else $param .= '&search_'.$key.'='.urlencode($search[$key]);
|
||||
}
|
||||
@ -387,8 +367,7 @@ $objecttmp = new StockTransfer($db);
|
||||
$trackid = 'xxxx'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($search_all)
|
||||
{
|
||||
if ($search_all) {
|
||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
@ -403,8 +382,7 @@ $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $ob
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
if (!empty($moreforfilter))
|
||||
{
|
||||
if (!empty($moreforfilter)) {
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
@ -421,21 +399,18 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
|
||||
// Fields title search
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
if (!empty($arrayfields['t.'.$key]['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
|
||||
if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
|
||||
elseif (strpos($val['type'], 'integer:') === 0) {
|
||||
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
|
||||
}
|
||||
elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
||||
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
@ -457,15 +432,13 @@ print '</tr>'."\n";
|
||||
// Fields title label
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
||||
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
if (!empty($arrayfields['t.'.$key]['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
|
||||
}
|
||||
}
|
||||
@ -482,10 +455,8 @@ print '</tr>'."\n";
|
||||
|
||||
// Detect if we need a fetch on each output line
|
||||
$needToFetchEachLine = 0;
|
||||
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
|
||||
{
|
||||
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
|
||||
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
|
||||
}
|
||||
}
|
||||
@ -495,8 +466,7 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
|
||||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < ($limit ? min($num, $limit) : $num))
|
||||
{
|
||||
while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) break; // Should not happen
|
||||
|
||||
@ -505,8 +475,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
||||
|
||||
// Show here line of result
|
||||
print '<tr class="oddeven">';
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
foreach ($object->fields as $key => $val) {
|
||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
@ -517,23 +486,21 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
||||
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
||||
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
|
||||
|
||||
if (!empty($arrayfields['t.'.$key]['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
||||
if ($key == 'status') print $object->getLibStatut(5);
|
||||
else {
|
||||
print $object->showOutputField($val, $key, $object->$key, '');
|
||||
if($key === 'date_prevue_depart' && $object->lead_time_for_warning > 0 && $object->$key > 0) {
|
||||
if ($key === 'date_prevue_depart' && $object->lead_time_for_warning > 0 && $object->$key > 0) {
|
||||
$date_prevue_depart = $object->$key;
|
||||
$date_prevue_depart_plus_delai = $date_prevue_depart;
|
||||
if($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day');
|
||||
if($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
|
||||
if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day');
|
||||
if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!empty($val['isameasure']))
|
||||
{
|
||||
if (!empty($val['isameasure'])) {
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
|
||||
$totalarray['val']['t.'.$key] += $object->$key;
|
||||
}
|
||||
@ -547,8 +514,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print '<td class="nowrap center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
$selected = 0;
|
||||
if (in_array($object->id, $arrayofselected)) $selected = 1;
|
||||
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||
@ -565,8 +531,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
||||
|
||||
// If no record found
|
||||
if ($num == 0)
|
||||
{
|
||||
if ($num == 0) {
|
||||
$colspan = 1;
|
||||
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
@ -584,8 +549,7 @@ print '</div>'."\n";
|
||||
|
||||
print '</form>'."\n";
|
||||
|
||||
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
|
||||
{
|
||||
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
|
||||
$hidegeneratedfilelistifempty = 1;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
|
||||
|
||||
|
||||
@ -90,8 +90,7 @@ $form = new Form($db);
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans('ModuleStockTransferName'), $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = stocktransferPrepareHead($object);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user