Skip to content

Commit

Permalink
Fix phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Apr 8, 2019
1 parent 917b9d6 commit 1274d71
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 469 deletions.
2 changes: 1 addition & 1 deletion htdocs/cashdesk/class/Facturation.class.php
Expand Up @@ -145,7 +145,7 @@ public function ajoutArticle()

$i = 0;
if (!is_null($newcartarray) && !empty($newcartarray)) {
$i=count($newcartarray);
$i=count($newcartarray);
}

$newcartarray[$i]['id']=$i;
Expand Down
9 changes: 5 additions & 4 deletions htdocs/categories/class/categorie.class.php
Expand Up @@ -984,10 +984,11 @@ protected function load_motherof()
* fullpath = chemin complet compose des id
*
* @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...).
* @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id.
* $markafterid can be an : int (id of category)
* string (categories ids seprated by comma)
* array (list of categories ids)
* @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id.
* $markafterid can be an :
* - int (id of category)
* - string (categories ids seprated by comma)
* - array (list of categories ids)
* @param int $include [=0] Removed or 1=Keep only
* @return array|int Array of categories. this->cats and this->motherof are set, -1 on error
*/
Expand Down
38 changes: 19 additions & 19 deletions htdocs/compta/facture/class/api_invoices.class.php
Expand Up @@ -952,24 +952,24 @@ public function markAsCreditAvailable($id)
if ($this->invoice->paye) {
throw new RestException(500, 'Alreay payed');
}

$this->invoice->fetch($id);
$this->invoice->fetch_thirdparty();

// Check if there is already a discount (protection to avoid duplicate creation when resubmit post)
$discountcheck=new DiscountAbsolute($this->db);
$result=$discountcheck->fetch(0, $this->invoice->id);

$canconvert=0;
if ($this->invoice->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc)
if (($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_STANDARD) && $this->invoice->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc)
if ($canconvert)
{
$this->db->begin();

$amount_ht = $amount_tva = $amount_ttc = array();
$multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();

// Loop on each vat rate
$i = 0;
foreach ($this->invoice->lines as $line)
Expand All @@ -985,13 +985,13 @@ public function markAsCreditAvailable($id)
$i++;
}
}

// Insert one discount by VAT rate category
$discount = new DiscountAbsolute($this->db);
if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE){
if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) {
$discount->description = '(CREDIT_NOTE)';
}
elseif ($this->invoice->type == Facture::TYPE_DEPOSIT){
elseif ($this->invoice->type == Facture::TYPE_DEPOSIT) {
$discount->description = '(DEPOSIT)';
}
elseif ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) {
Expand All @@ -1000,16 +1000,16 @@ public function markAsCreditAvailable($id)
else {
throw new RestException(500, 'Cant convert to reduc an Invoice of this type');
}

$discount->fk_soc = $this->invoice->socid;
$discount->fk_facture_source = $this->invoice->id;

$error = 0;

if ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION)
{
// If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT

// Total payments
$sql = 'SELECT SUM(pf.amount) as total_paiements';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p';
Expand All @@ -1019,10 +1019,10 @@ public function markAsCreditAvailable($id)
$sql.= ' AND p.entity IN ('.getEntity('invoice').')';
$resql = $this->db->query($sql);
if (! $resql) dol_print_error($this->db);

$res = $this->db->fetch_object($resql);
$total_paiements = $res->total_paiements;

// Total credit note and deposit
$total_creditnote_and_deposit = 0;
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
Expand All @@ -1033,11 +1033,11 @@ public function markAsCreditAvailable($id)
if (!empty($resql)) {
while ($obj = $this->db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc;
} else dol_print_error($this->db);

$discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $this->invoice->total_ttc;
$discount->amount_tva = 0;
$discount->tva_tx = 0;

$result = $discount->create(DolibarrApiAccess::$user);
if ($result < 0)
{
Expand All @@ -1055,7 +1055,7 @@ public function markAsCreditAvailable($id)
$discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]);
$discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]);
$discount->tva_tx = abs($tva_tx);

$result = $discount->create(DolibarrApiAccess::$user);
if ($result < 0)
{
Expand All @@ -1064,7 +1064,7 @@ public function markAsCreditAvailable($id)
}
}
}

if (empty($error))
{
if($this->invoice->type != Facture::TYPE_DEPOSIT) {
Expand All @@ -1089,7 +1089,7 @@ public function markAsCreditAvailable($id)
throw new RestException(500, 'Discount creation error');
}
}

return $this->_cleanObjectDatas($this->invoice);
}

Expand Down
14 changes: 7 additions & 7 deletions htdocs/core/class/commondocgenerator.class.php
Expand Up @@ -1071,14 +1071,14 @@ public function getColumnStatus($colKey)
}

/**
* print standard column content
* Print standard column content
*
* @param PDF $pdf pdf object
* @param float $tab_top tab top position
* @param float $tab_height default tab height
* @param $outputlangs
* @param int $hidetop
* @return float height of col tab titles
* @param PDF $pdf Pdf object
* @param float $tab_top Tab top position
* @param float $tab_height Default tab height
* @param Translate $outputlangs Output language
* @param int $hidetop Hide top
* @return float Height of col tab titles
*/
function pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop = 0)
{
Expand Down
7 changes: 4 additions & 3 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -3806,9 +3806,10 @@ public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account
* @param string $htmlname HTML field name
* @param int $maxlength Maximum length for labels
* @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id.
* $markafterid can be an : int (id of category)
* string (categories ids seprated by comma)
* array (list of categories ids)
* $markafterid can be an :
* - int (id of category)
* - string (categories ids seprated by comma)
* - array (list of categories ids)
* @param int $outputmode 0=HTML select string, 1=Array
* @param int $include [=0] Removed or 1=Keep only
* @return string
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/commande/doc/pdf_einstein.modules.php
Expand Up @@ -116,7 +116,7 @@ class pdf_einstein extends ModelePDFCommandes

/**
* Issuer
* @var Company object that emits
* @var Societe object that emits
*/
public $emetteur;

Expand Down
68 changes: 33 additions & 35 deletions htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
Expand Up @@ -83,32 +83,32 @@ class pdf_eratosthene extends ModelePDFCommandes
* @var int page_largeur
*/
public $page_largeur;

/**
* @var int page_hauteur
*/
public $page_hauteur;

/**
* @var array format
*/
public $format;

/**
* @var int marge_gauche
*/
public $marge_gauche;

/**
* @var int marge_droite
*/
public $marge_droite;

/**
* @var int marge_haute
*/
public $marge_haute;

/**
* @var int marge_basse
*/
Expand Down Expand Up @@ -209,38 +209,38 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
$hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
}

// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
$this->atleastonephoto = false;
if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
{
$objphoto = new Product($this->db);

for ($i = 0 ; $i < $nblignes ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;

$objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
$pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
$pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/";
$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/';
}
else
{
$pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default
$pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/"; // alternative
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default
$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; // alternative
}

$arephoto = false;
foreach ($pdir as $midir)
{
if (! $arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;

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
Expand All @@ -258,19 +258,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
{
$filename=$obj['photo'];
}

$realpath = $dir.$filename;
$arephoto = true;
$this->atleastonephoto = true;
}
}
}

if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
}
}



if ($conf->commande->dir_output)
{
Expand Down Expand Up @@ -541,11 +541,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$pdf->startTransaction();
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
$pdf->rollbackTransaction(true);

$iniY = $tab_top + $this->tabTitleHeight + 2;
$curY = $tab_top + $this->tabTitleHeight + 2;
$nexY = $tab_top + $this->tabTitleHeight + 2;

// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
$pagenb = $pageposbeforeprintlines;
Expand All @@ -554,7 +554,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);

// Define size of image if we need it
$imglinesize=array();
if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
Expand All @@ -569,20 +569,20 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$showpricebeforepagebreak=1;
$posYAfterImage=0;
$posYAfterDescription=0;

if($this->getColumnStatus('photo'))
{
// 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
{
$pdf->AddPage('','',true);
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pdf->setPage($pageposbefore+1);

$curY = $tab_top_newpage;
$showpricebeforepagebreak=0;
}

if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
Expand Down Expand Up @@ -628,11 +628,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$posYAfterDescription=$pdf->GetY();
}

$nexY = max($pdf->GetY(),$posYAfterImage);


$nexY = max($pdf->GetY(), $posYAfterImage);


$pageposafter=$pdf->getPage();

$pdf->setPage($pageposbefore);
Expand Down Expand Up @@ -1088,7 +1088,7 @@ private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs
$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);

// Show VAT by rates and total
$pdf->SetFillColor(248, 248, 248);

Expand Down Expand Up @@ -1354,12 +1354,10 @@ private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hi


$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);

if (empty($hidetop)){
$pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line prend une position y en 2eme param et 4eme param
}


}

/**
Expand Down

0 comments on commit 1274d71

Please sign in to comment.