diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index b0117e43557..75ad8e6d226 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -45,7 +45,35 @@ if (!$user->admin) /* * Actions */ - +if ($_GET["action"] == 'specimen') +{ + $modele=$_GET["module"]; + + $inter = new Fichinter($db); + $inter->initAsSpecimen(); + + // Charge le modele + $dir = DOL_DOCUMENT_ROOT . "/includes/modules/fichinter/"; + $file = "pdf_".$modele.".modules.php"; + if (file_exists($dir.$file)) + { + $classname = "pdf_".$modele; + require_once($dir.$file); + + $obj = new $classname($db); + + if ($obj->write_pdf_file($inter,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf"); + return; + } + } + else + { + $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + } +} + if ($_GET["action"] == 'set') { $type='ficheinter'; diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index 39d133c12be..11f6df676e8 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -813,11 +813,85 @@ class Fichinter extends CommonObject } } } + + /** + * \brief Initialise la fiche intervention avec valeurs fictives aléatoire + * Sert à générer une fiche intervention pour l'aperu des modèles ou demo + */ + function initAsSpecimen() + { + global $user,$langs; + + // Charge tableau des id de société socids + $socids = array(); + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10"; + $resql = $this->db->query($sql); + if ($resql) + { + $num_socs = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_socs) + { + $i++; + + $row = $this->db->fetch_row($resql); + $socids[$i] = $row[0]; + } + } + + // Charge tableau des produits prodids + $prodids = array(); + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=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]; + } + } + + // Initialise paramètres + $this->id=0; + $this->ref = 'SPECIMEN'; + $this->specimen=1; + $socid = rand(1, $num_socs); + $this->socid = $socids[$socid]; + $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'; + $nbp = 5; + $xnbp = 0; + while ($xnbp < $nbp) + { + $ligne=new FichinterLigne($this->db); + $ligne->desc=$langs->trans("Description")." ".$xnbp; + $ligne->qty=1; + $ligne->subprice=100; + $ligne->price=100; + $ligne->tva_tx=19.6; + $prodid = rand(1, $num_prods); + $ligne->produit_id=$prodids[$prodid]; + $this->lignes[$xnbp]=$ligne; + $xnbp++; + } + + $this->amount_ht = $xnbp*100; + $this->total_ht = $xnbp*100; + $this->total_tva = $xnbp*19.6; + $this->total_ttc = $xnbp*119.6; + } } /** - \class FichinterLigne + \class FichinterLigne \brief Classe permettant la gestion des lignes d'intervention */ diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index 3eb20272f39..e8507bcf2b5 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -61,6 +61,13 @@ class pdf_soleil extends ModelePDFFicheinter $this->marge_droite=10; $this->marge_haute=10; $this->marge_basse=10; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 0; // Affiche mode règlement + $this->option_condreg = 0; // Affiche conditions règlement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 0; // Dispo en plusieurs langues // Recupere code pays de l'emmetteur $this->emetteur=$mysoc;