| ';
print (empty($module->name) ? $name : $module->name);
print " | \n";
@@ -451,8 +418,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print ' | ';
// Active
- if (in_array($name, $def))
- {
+ if (in_array($name, $def)) {
print ''."\n";
print '';
print img_picto($langs->trans("Enabled"), 'switch_on');
@@ -467,8 +433,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Default
print ' | ';
$constforvar = 'STOCKTRANSFER_'.strtoupper($myTmpObjectKey).'_ADDON';
- if ($conf->global->$constforvar == $name)
- {
+ if ($conf->global->$constforvar == $name) {
print img_picto($langs->trans("Default"), 'on');
} else {
print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'';
@@ -478,8 +443,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= ' '.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
- if ($module->type == 'pdf')
- {
+ if ($module->type == 'pdf') {
$htmltooltip .= ' '.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= ' '.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@@ -494,8 +458,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
// Preview
print ' | ';
- if ($module->type == 'pdf')
- {
+ if ($module->type == 'pdf') {
print ''.img_object($langs->trans("Preview"), 'generic').'';
} else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 5c82d1237f6..25f46e6232a 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -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);
diff --git a/htdocs/core/modules/modStockTransfer.class.php b/htdocs/core/modules/modStockTransfer.class.php
index e60ea3c330d..d15e9797d13 100644
--- a/htdocs/core/modules/modStockTransfer.class.php
+++ b/htdocs/core/modules/modStockTransfer.class.php
@@ -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 {
diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
index 9f9edaadb7a..2bffdf68b2d 100644
--- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
+++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
@@ -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")." ";
$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);
diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php
index a349f4f536e..fab0952e894 100644
--- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php
+++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php
@@ -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;
}
diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php
index 77236ec0e40..6a6c7c556e6 100644
--- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php
+++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php
@@ -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;
}
diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php
index dcdf46b75e6..e4754a1c301 100644
--- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php
+++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php
@@ -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 = '';
@@ -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 .= '';
- }
- else {
+ } else {
$result .= '';
}
$result .= '';
- }
- 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 "";
}
diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php
index 35d79dda95d..46aeba5980e 100644
--- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php
+++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php
@@ -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 = '';
@@ -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 .= '';
- }
- else {
+ } else {
$result .= '';
}
$result .= '';
- }
- 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 "";
}
diff --git a/htdocs/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php b/htdocs/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php
index 03999b712e6..232229a014d 100644
--- a/htdocs/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php
+++ b/htdocs/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php
@@ -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++;
diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php
index cc580d2ab4a..b260dfc8d76 100644
--- a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php
+++ b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php
@@ -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.='';
- 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 ''.$langs->trans("AddAction").'';
- }
- else
- {
+ } else {
print ''.$langs->trans("AddAction").'';
}
}
print '';
- 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);
diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php
index e16d2514661..cf7f291ce18 100644
--- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php
+++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php
@@ -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 ' |