From 9b553db50842146f4ed4e2c0105445bb06b50605 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2011 18:43:01 +0000 Subject: [PATCH] Fix: Syntax error --- htdocs/admin/fichinter.php | 4 +- htdocs/fichinter/class/fichinter.class.php | 43 +++++++++++++++---- .../modules/fichinter/pdf_soleil.modules.php | 31 +++++-------- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 105328889bc..0cfeb8874f8 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -33,7 +33,8 @@ require_once(DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'); $langs->load("admin"); $langs->load("errors"); -$langs->load("interventions"); +/*$langs->load("other"); +$langs->load("interventions");*/ if (!$user->admin) accessforbidden(); @@ -41,7 +42,6 @@ accessforbidden(); $action = GETPOST("action"); $value = GETPOST("value"); - /* * Actions */ diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index b1b8ad1ebce..c72d3515fb9 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -758,30 +758,57 @@ class Fichinter extends CommonObject { global $user,$langs,$conf; - $now=dol_now(); + // Charge tableau des produits prodids + $prodids = array(); + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql.= " WHERE entity = ".$conf->entity; + $sql.= " AND tosell = 1"; + $resql = $this->db->query($sql); + if ($resql) + { + $num_prods = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_prods) + { + $i++; + $row = $this->db->fetch_row($resql); + $prodids[$i] = $row[0]; + } + } + else dol_print_error($this->db); // Initialise parametres $this->id=0; $this->ref = 'SPECIMEN'; $this->specimen=1; $this->socid = 1; - $this->date = $now; + $this->date = time(); + $this->date_lim_reglement=$this->date+3600*24*30; + $this->cond_reglement_code = 'RECEP'; + $this->mode_reglement_code = 'CHQ'; $this->note_public='SPECIMEN'; - $this->duree = 0; $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { $line=new FichinterLigne($this->db); $line->desc=$langs->trans("Description")." ".$xnbp; - $line->datei=($now-3600*(1+$xnbp)); - $line->duration=600; - $line->fk_fichinter=0; + $line->qty=1; + $line->subprice=100; + $line->price=100; + $line->tva_tx=19.6; + $prodid = rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + $this->lines[$xnbp]=$line; $xnbp++; - - $this->duree+=$line->duration; } + + $this->amount_ht = $xnbp*100; + $this->total_ht = $xnbp*100; + $this->total_tva = $xnbp*19.6; + $this->total_ttc = $xnbp*119.6; } /** diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index 2fe9a76b3f7..47406f7f210 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -2,7 +2,6 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2011 Fabrice CHERRIER (12/05/2011) http://www.fcinc.fr * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +26,6 @@ require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); -require_once(DOL_DOCUMENT_ROOT.'/lib/date.lib.php'); /** @@ -272,32 +270,25 @@ class pdf_soleil extends ModelePDFFicheinter $height_note=0; } - $pdf->SetXY($this->marge_gauche, $tab_top); + $pdf->SetXY (10, $tab_top); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); - $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8 ); + $pdf->line(10, $tab_top + 8, 200, $tab_top + 8 ); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 - $pdf->SetXY($this->marge_gauche, $tab_top + 8 ); - $text=$fichinter->description; - if ($fichinter->duree > 0) - { - $totaltime=ConvertSecondToTime($fichinter->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY); - $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime; - } - $desc=dol_htmlentitiesbr($text,1); + $pdf->SetXY (10, $tab_top + 8 ); + $desc=dol_htmlentitiesbr($fichinter->description,1); //print $outputlangs->convToOutputCharset($desc); exit; - $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1); $nexY = $pdf->GetY(); - $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY); + $pdf->line(10, $nexY, 200, $nexY); $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. //dol_syslog("desc=".dol_htmlentitiesbr($fichinter->description)); - $nblignes = count($fichinter->lines); + $nblignes = sizeof($fichinter->lines); $curY = $pdf->GetY(); $nexY = $pdf->GetY(); @@ -308,16 +299,16 @@ class pdf_soleil extends ModelePDFFicheinter $fichinterligne = $fichinter->lines[$i]; $valide = $fichinterligne->id ? $fichinterligne->fetch($fichinterligne->id) : 0; - if ($valide>0 || $fichinter->specimen) + if ($valide>0) { $curY = $nexY+3; - $pdf->SetXY($this->marge_gauche, $curY); + $pdf->SetXY (10, $curY); $pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY, dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".dol_print_date($fichinterligne->datei,'dayhour',false,$outputlangs,true)." - ".$outputlangs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration),1,$outputlangs->charset_output), 0, 1, 0); $nexY = $pdf->GetY(); - $pdf->SetXY($this->marge_gauche, $curY + 3); + $pdf->SetXY (10, $curY + 3); $desc = dol_htmlentitiesbr($fichinterligne->desc,1); $pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY + 3, $desc, 0, 1, 0); $nexY+=dol_nboflines_bis($fichinterligne->desc,52,$outputlangs->charset_output)*3; @@ -326,8 +317,8 @@ class pdf_soleil extends ModelePDFFicheinter //$pdf->line(10, $tab_top+$tab_height+3, 200, $tab_top+$tab_height+3); // Rectangle for title and all lines - $pdf->Rect($this->marge_gauche, $tab_top, ($this->page_largeur-$this->marge_gauche-$this->marge_droite), $tab_height+3); - $pdf->SetXY($this->marge_gauche, $pdf->GetY() + 20); + $pdf->Rect(10, $tab_top, 190, $tab_height+3); + $pdf->SetXY (10, $pdf->GetY() + 20); $pdf->MultiCell(60, 5, '', 0, 'J', 0); $pdf->SetXY(20,220);