On fait march l'apercu du specimen des modeles expedition
This commit is contained in:
parent
5ee986de3b
commit
ffcfab529c
@ -32,6 +32,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/expedition/expedition.class.php');
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("bills");
|
||||
@ -45,6 +46,35 @@ if (!$user->admin) accessforbidden();
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($_GET["action"] == 'specimen')
|
||||
{
|
||||
$modele=$_GET["module"];
|
||||
|
||||
$exp = new Expedition($db);
|
||||
$exp->initAsSpecimen();
|
||||
$exp->fetch_commande();
|
||||
|
||||
// Charge le modele
|
||||
$dir = DOL_DOCUMENT_ROOT . "/expedition/mods/pdf/";
|
||||
$file = "pdf_expedition_".$modele.".modules.php";
|
||||
if (file_exists($dir.$file))
|
||||
{
|
||||
$classname = "pdf_expedition_".$modele;
|
||||
require_once($dir.$file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
if ($obj->write_file($exp,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'set')
|
||||
{
|
||||
@ -128,6 +158,9 @@ if ($_GET["action"] == 'setmod')
|
||||
|
||||
llxHeader("","");
|
||||
|
||||
if ($mesg) print $mesg.'<br>';
|
||||
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/";
|
||||
$html=new Form($db);
|
||||
|
||||
@ -345,9 +378,9 @@ if(is_dir($dir))
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br><b>'.$langs->trans("Width").'</b>: '.$module->page_largeur;
|
||||
$htmltooltip.='<br><b>'.$langs->trans("Height").'</b>: '.$module->page_hauteur;
|
||||
$htmltooltip = '<b>'.$langs->trans("Name").'</b>: '.$module->name;
|
||||
$htmltooltip.='<br><b>'.$langs->trans("Type").'</b>: '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br><b>'.$langs->trans("Width").'/'.$langs->trans("Height").'</b>: '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br>'.$langs->trans("FeaturesSupported").':';
|
||||
$htmltooltip.='<br><b>'.$langs->trans("Logo").'</b>: '.yn($module->option_logo);
|
||||
print '<td align="center">';
|
||||
|
||||
@ -64,12 +64,16 @@ if ($_GET["action"] == 'specimen')
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
if ($obj->write_pdf_file($facture) > 0)
|
||||
if ($obj->write_pdf_file($facture,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'set')
|
||||
|
||||
@ -41,15 +41,16 @@ $original_file = urldecode($_GET["file"]);
|
||||
$modulepart = urldecode($_GET["modulepart"]);
|
||||
$urlsource = urldecode($_GET["urlsource"]);
|
||||
// Défini type (attachment=1 pour forcer popup 'enregistrer sous')
|
||||
$type = urldecode($_GET["type"]); $attachment = true;
|
||||
if (eregi('\.sql',$original_file)) { $type='text/plain'; $attachment = true; }
|
||||
if (eregi('\.html',$original_file)) { $type='text/html'; $attachment = false; }
|
||||
if (eregi('\.csv',$original_file)) { $type='text/csv'; $attachment = true; }
|
||||
if (eregi('\.pdf',$original_file)) { $type='application/pdf'; $attachment = true; }
|
||||
if (eregi('\.xls',$original_file)) { $type='application/x-msexcel'; $attachment = true; }
|
||||
if (eregi('\.jpg',$original_file)) { $type='image/jpeg'; $attachment = true; }
|
||||
if (eregi('\.png',$original_file)) { $type='image/jpeg'; $attachment = true; }
|
||||
if (eregi('\.tiff',$original_file)) { $type='image/tiff'; $attachment = true; }
|
||||
$type = urldecode($_GET["type"]);
|
||||
$attachment = true;
|
||||
if (eregi('\.sql$',$original_file)) { $type='text/plain'; $attachment = true; }
|
||||
if (eregi('\.html$',$original_file)) { $type='text/html'; $attachment = false; }
|
||||
if (eregi('\.csv$',$original_file)) { $type='text/csv'; $attachment = true; }
|
||||
if (eregi('\.pdf$',$original_file)) { $type='application/pdf'; $attachment = true; }
|
||||
if (eregi('\.xls$',$original_file)) { $type='application/x-msexcel'; $attachment = true; }
|
||||
if (eregi('\.jpg$',$original_file)) { $type='image/jpeg'; $attachment = true; }
|
||||
if (eregi('\.png$',$original_file)) { $type='image/jpeg'; $attachment = true; }
|
||||
if (eregi('\.tiff$',$original_file)) { $type='image/tiff'; $attachment = true; }
|
||||
|
||||
//Suppression de la chaine de caractère ../ dans $original_file
|
||||
$original_file = str_replace("../","/", "$original_file");
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
|
||||
|
||||
/**
|
||||
@ -571,15 +572,15 @@ class Expedition extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Lit la commande associée
|
||||
*
|
||||
*/
|
||||
function fetch_commande()
|
||||
{
|
||||
$this->commande =& new Commande($this->db);
|
||||
$this->commande->fetch($this->commande_id);
|
||||
}
|
||||
/*
|
||||
* Lit la commande associée
|
||||
*
|
||||
*/
|
||||
function fetch_commande()
|
||||
{
|
||||
$this->commande =& new Commande($this->db);
|
||||
$this->commande->fetch($this->commande_id);
|
||||
}
|
||||
|
||||
|
||||
function fetch_lignes()
|
||||
@ -653,7 +654,78 @@ class Expedition extends CommonObject
|
||||
if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialise la facture avec valeurs fictives aléatoire
|
||||
* Sert à générer une facture 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 idp 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->statut = 1;
|
||||
$this->commande_id = 0;
|
||||
if ($conf->livraison->enabled)
|
||||
{
|
||||
$this->livraison_id = 0;
|
||||
}
|
||||
$this->date = time();
|
||||
$this->entrepot_id = 0;
|
||||
$this->adresse_livraison_id = 0;
|
||||
$this->socidp = $socids[$socid];
|
||||
|
||||
$nbp = 5;
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp)
|
||||
{
|
||||
$ligne=new ExpeditionLigne($this->db);
|
||||
$ligne->desc=$langs->trans("Description")." ".$xnbp;
|
||||
$ligne->libelle=$langs->trans("Description")." ".$xnbp;
|
||||
$ligne->qty=10;
|
||||
$ligne->qty_expedition=5;
|
||||
$prodid = rand(1, $num_prods);
|
||||
$ligne->fk_product=$prodids[$prodid];
|
||||
$xnbp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -142,6 +142,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||
// Sauvegarde le dernier modèle choisi pour générer un document
|
||||
$expedition = new Expedition($db, 0, $_REQUEST['id']);
|
||||
$expedition->fetch($_REQUEST['id']);
|
||||
$expedition->fetch_commande();
|
||||
if ($_REQUEST['model'])
|
||||
{
|
||||
$expedition->set_pdf_model($user, $_REQUEST['model']);
|
||||
@ -152,7 +153,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
$result=expedition_pdf_create($db, $expedition->id,$expedition->modelpdf,$outputlangs);
|
||||
$result=expedition_pdf_create($db,$expedition->id,$expedition->modelpdf,$outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dolibarr_print_error($db,$result);
|
||||
|
||||
@ -77,7 +77,7 @@ Class ModelePdfExpedition extends DolibarrPdfBarCode
|
||||
/*
|
||||
\brief Crée un bon d'expedition sur disque
|
||||
\param db objet base de donnée
|
||||
\param id id de la propale à créer
|
||||
\param id id de la expedition à créer
|
||||
\param modele force le modele à utiliser ('' par defaut)
|
||||
\param outputlangs objet lang a utiliser pour traduction
|
||||
*/
|
||||
@ -123,12 +123,7 @@ function expedition_pdf_create($db, $id, $modele='', $outputlangs='')
|
||||
$expedition = new Expedition($db);
|
||||
$result=$expedition->fetch($id);
|
||||
|
||||
$expeditionref = sanitize_string($expedition->ref);
|
||||
$dir = $conf->expedition->dir_output . "/" . $expeditionref;
|
||||
$file = $dir . "/" . $expeditionref . ".pdf";
|
||||
|
||||
if ($obj->generate($expedition, $file) > 0)
|
||||
// if ( $obj->write_pdf_file($id, $outputlangs) > 0)
|
||||
if ($obj->write_file($expedition, $langs) > 0)
|
||||
{
|
||||
// on supprime l'image correspondant au preview
|
||||
// expedition_delete_preview($db, $id);
|
||||
|
||||
@ -73,11 +73,12 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
}
|
||||
|
||||
|
||||
//*****************************
|
||||
//Creation du Document
|
||||
//Initialisation des données
|
||||
//*****************************
|
||||
function generate(&$objExpe, $file, $outputlangs='')
|
||||
/**
|
||||
* \brief Fonction générant le document sur le disque
|
||||
* \param obj Objet expedition à générer (ou id si ancienne methode)
|
||||
* \return int 1=ok, 0=ko
|
||||
*/
|
||||
function write_file(&$obj, $outputlangs='')
|
||||
{
|
||||
global $user,$conf,$langs;
|
||||
|
||||
@ -92,8 +93,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$outputlangs->setPhpLang();
|
||||
|
||||
//Generation de la fiche
|
||||
$this->expe = $objExpe;
|
||||
$this->expe->fetch_commande();
|
||||
$this->expe = $obj;
|
||||
|
||||
//Verification de la configuration
|
||||
if ($conf->expedition->dir_output)
|
||||
@ -210,10 +210,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
}
|
||||
//Insertion du pied de page
|
||||
$this->_pagefoot($pdf);
|
||||
|
||||
$pdf->AliasNbPages();
|
||||
//Cloture du pdf
|
||||
|
||||
$pdf->Close();
|
||||
//Ecriture du pdf
|
||||
|
||||
$pdf->Output($file);
|
||||
|
||||
$langs->setPhpLang(); // On restaure langue session
|
||||
|
||||
@ -114,7 +114,13 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
|
||||
$pdf->Text($posx, 60, $outputlangs->trans("Date")." : ".dolibarr_print_date($this->expe->commande->date,"%d %b %Y"));
|
||||
}
|
||||
|
||||
function generate(&$objExpe, $filename, $outputlangs='')
|
||||
|
||||
/**
|
||||
* \brief Fonction générant le document sur le disque
|
||||
* \param obj Objet expedition à générer (ou id si ancienne methode)
|
||||
* \return int 1=ok, 0=ko
|
||||
*/
|
||||
function write_file(&$obj, $outputlangs='')
|
||||
{
|
||||
global $user,$conf,$langs;
|
||||
|
||||
@ -129,8 +135,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
|
||||
|
||||
if ($conf->expedition->dir_output)
|
||||
{
|
||||
$this->expe = $objExpe;
|
||||
$this->expe->fetch_commande();
|
||||
$this->expe = $obj;
|
||||
|
||||
// Définition de $dir et $file
|
||||
if ($this->expe->specimen)
|
||||
@ -253,8 +258,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
|
||||
|
||||
$pdf->Text(194, $curY, $this->expe->lignes[$i]->qty_expedition);
|
||||
}
|
||||
$pdf->AliasNbPages();
|
||||
|
||||
$pdf->Close();
|
||||
|
||||
$pdf->Output($filename);
|
||||
$pdf->Output($file);
|
||||
|
||||
$langs->setPhpLang(); // On restaure langue session
|
||||
return 1;
|
||||
|
||||
@ -2233,7 +2233,7 @@ class Facture extends CommonObject
|
||||
$this->cond_reglement_code = 'RECEP';
|
||||
$this->mode_reglement_code = 'CHQ';
|
||||
$this->note_public='SPECIMEN';
|
||||
$nbp = rand(1, 9);
|
||||
$nbp = 5;
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp)
|
||||
{
|
||||
|
||||
@ -573,5 +573,5 @@ DeliveriesOrderAbility=Prise en charge des bons de r
|
||||
ActivateFCKeditor=Activer FCKeditor pour :
|
||||
FCKeditorForCompany=Création/édition WYSIWIG des descriptions et notes des tiers
|
||||
FCKeditorForProductDescription=Création/édition WYSIWIG des notes des produits/services
|
||||
FCKeditorForDetails=Création/édition WYSIWIG des lignes details des entités (commandes, propales, factures, etc...)
|
||||
FCKeditorForDetails=Création/édition WYSIWIG des lignes details des produits (sur commandes, propales, factures, etc...)
|
||||
FCKeditorForMailing=Création/édition WYSIWIG des mailings
|
||||
|
||||
Loading…
Reference in New Issue
Block a user