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("./pre.inc.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT.'/expedition/expedition.class.php');
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -45,6 +46,35 @@ if (!$user->admin) accessforbidden();
|
|||||||
/*
|
/*
|
||||||
* Actions
|
* 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')
|
if ($_GET["action"] == 'set')
|
||||||
{
|
{
|
||||||
@ -128,6 +158,9 @@ if ($_GET["action"] == 'setmod')
|
|||||||
|
|
||||||
llxHeader("","");
|
llxHeader("","");
|
||||||
|
|
||||||
|
if ($mesg) print $mesg.'<br>';
|
||||||
|
|
||||||
|
|
||||||
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/";
|
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/";
|
||||||
$html=new Form($db);
|
$html=new Form($db);
|
||||||
|
|
||||||
@ -345,9 +378,9 @@ if(is_dir($dir))
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
$htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.($module->type?$module->type:$langs->trans("Unknown"));
|
$htmltooltip = '<b>'.$langs->trans("Name").'</b>: '.$module->name;
|
||||||
$htmltooltip.='<br><b>'.$langs->trans("Width").'</b>: '.$module->page_largeur;
|
$htmltooltip.='<br><b>'.$langs->trans("Type").'</b>: '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||||
$htmltooltip.='<br><b>'.$langs->trans("Height").'</b>: '.$module->page_hauteur;
|
$htmltooltip.='<br><b>'.$langs->trans("Width").'/'.$langs->trans("Height").'</b>: '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||||
$htmltooltip.='<br><br>'.$langs->trans("FeaturesSupported").':';
|
$htmltooltip.='<br><br>'.$langs->trans("FeaturesSupported").':';
|
||||||
$htmltooltip.='<br><b>'.$langs->trans("Logo").'</b>: '.yn($module->option_logo);
|
$htmltooltip.='<br><b>'.$langs->trans("Logo").'</b>: '.yn($module->option_logo);
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
|
|||||||
@ -64,12 +64,16 @@ if ($_GET["action"] == 'specimen')
|
|||||||
|
|
||||||
$obj = new $classname($db);
|
$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");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET["action"] == 'set')
|
if ($_GET["action"] == 'set')
|
||||||
|
|||||||
@ -41,15 +41,16 @@ $original_file = urldecode($_GET["file"]);
|
|||||||
$modulepart = urldecode($_GET["modulepart"]);
|
$modulepart = urldecode($_GET["modulepart"]);
|
||||||
$urlsource = urldecode($_GET["urlsource"]);
|
$urlsource = urldecode($_GET["urlsource"]);
|
||||||
// Défini type (attachment=1 pour forcer popup 'enregistrer sous')
|
// Défini type (attachment=1 pour forcer popup 'enregistrer sous')
|
||||||
$type = urldecode($_GET["type"]); $attachment = true;
|
$type = urldecode($_GET["type"]);
|
||||||
if (eregi('\.sql',$original_file)) { $type='text/plain'; $attachment = true; }
|
$attachment = true;
|
||||||
if (eregi('\.html',$original_file)) { $type='text/html'; $attachment = false; }
|
if (eregi('\.sql$',$original_file)) { $type='text/plain'; $attachment = true; }
|
||||||
if (eregi('\.csv',$original_file)) { $type='text/csv'; $attachment = true; }
|
if (eregi('\.html$',$original_file)) { $type='text/html'; $attachment = false; }
|
||||||
if (eregi('\.pdf',$original_file)) { $type='application/pdf'; $attachment = true; }
|
if (eregi('\.csv$',$original_file)) { $type='text/csv'; $attachment = true; }
|
||||||
if (eregi('\.xls',$original_file)) { $type='application/x-msexcel'; $attachment = true; }
|
if (eregi('\.pdf$',$original_file)) { $type='application/pdf'; $attachment = true; }
|
||||||
if (eregi('\.jpg',$original_file)) { $type='image/jpeg'; $attachment = true; }
|
if (eregi('\.xls$',$original_file)) { $type='application/x-msexcel'; $attachment = true; }
|
||||||
if (eregi('\.png',$original_file)) { $type='image/jpeg'; $attachment = true; }
|
if (eregi('\.jpg$',$original_file)) { $type='image/jpeg'; $attachment = true; }
|
||||||
if (eregi('\.tiff',$original_file)) { $type='image/tiff'; $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
|
//Suppression de la chaine de caractère ../ dans $original_file
|
||||||
$original_file = str_replace("../","/", "$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."/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
|
* Lit la commande associée
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function fetch_commande()
|
function fetch_commande()
|
||||||
{
|
{
|
||||||
$this->commande =& new Commande($this->db);
|
$this->commande =& new Commande($this->db);
|
||||||
$this->commande->fetch($this->commande_id);
|
$this->commande->fetch($this->commande_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function fetch_lignes()
|
function fetch_lignes()
|
||||||
@ -653,7 +654,78 @@ class Expedition extends CommonObject
|
|||||||
if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated');
|
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
|
// Sauvegarde le dernier modèle choisi pour générer un document
|
||||||
$expedition = new Expedition($db, 0, $_REQUEST['id']);
|
$expedition = new Expedition($db, 0, $_REQUEST['id']);
|
||||||
$expedition->fetch($_REQUEST['id']);
|
$expedition->fetch($_REQUEST['id']);
|
||||||
|
$expedition->fetch_commande();
|
||||||
if ($_REQUEST['model'])
|
if ($_REQUEST['model'])
|
||||||
{
|
{
|
||||||
$expedition->set_pdf_model($user, $_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 = new Translate(DOL_DOCUMENT_ROOT ."/langs");
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
$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)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db,$result);
|
dolibarr_print_error($db,$result);
|
||||||
|
|||||||
@ -77,7 +77,7 @@ Class ModelePdfExpedition extends DolibarrPdfBarCode
|
|||||||
/*
|
/*
|
||||||
\brief Crée un bon d'expedition sur disque
|
\brief Crée un bon d'expedition sur disque
|
||||||
\param db objet base de donnée
|
\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 modele force le modele à utiliser ('' par defaut)
|
||||||
\param outputlangs objet lang a utiliser pour traduction
|
\param outputlangs objet lang a utiliser pour traduction
|
||||||
*/
|
*/
|
||||||
@ -123,12 +123,7 @@ function expedition_pdf_create($db, $id, $modele='', $outputlangs='')
|
|||||||
$expedition = new Expedition($db);
|
$expedition = new Expedition($db);
|
||||||
$result=$expedition->fetch($id);
|
$result=$expedition->fetch($id);
|
||||||
|
|
||||||
$expeditionref = sanitize_string($expedition->ref);
|
if ($obj->write_file($expedition, $langs) > 0)
|
||||||
$dir = $conf->expedition->dir_output . "/" . $expeditionref;
|
|
||||||
$file = $dir . "/" . $expeditionref . ".pdf";
|
|
||||||
|
|
||||||
if ($obj->generate($expedition, $file) > 0)
|
|
||||||
// if ( $obj->write_pdf_file($id, $outputlangs) > 0)
|
|
||||||
{
|
{
|
||||||
// on supprime l'image correspondant au preview
|
// on supprime l'image correspondant au preview
|
||||||
// expedition_delete_preview($db, $id);
|
// expedition_delete_preview($db, $id);
|
||||||
|
|||||||
@ -73,11 +73,12 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//*****************************
|
/**
|
||||||
//Creation du Document
|
* \brief Fonction générant le document sur le disque
|
||||||
//Initialisation des données
|
* \param obj Objet expedition à générer (ou id si ancienne methode)
|
||||||
//*****************************
|
* \return int 1=ok, 0=ko
|
||||||
function generate(&$objExpe, $file, $outputlangs='')
|
*/
|
||||||
|
function write_file(&$obj, $outputlangs='')
|
||||||
{
|
{
|
||||||
global $user,$conf,$langs;
|
global $user,$conf,$langs;
|
||||||
|
|
||||||
@ -92,8 +93,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
|||||||
$outputlangs->setPhpLang();
|
$outputlangs->setPhpLang();
|
||||||
|
|
||||||
//Generation de la fiche
|
//Generation de la fiche
|
||||||
$this->expe = $objExpe;
|
$this->expe = $obj;
|
||||||
$this->expe->fetch_commande();
|
|
||||||
|
|
||||||
//Verification de la configuration
|
//Verification de la configuration
|
||||||
if ($conf->expedition->dir_output)
|
if ($conf->expedition->dir_output)
|
||||||
@ -210,10 +210,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
|||||||
}
|
}
|
||||||
//Insertion du pied de page
|
//Insertion du pied de page
|
||||||
$this->_pagefoot($pdf);
|
$this->_pagefoot($pdf);
|
||||||
|
|
||||||
$pdf->AliasNbPages();
|
$pdf->AliasNbPages();
|
||||||
//Cloture du pdf
|
|
||||||
$pdf->Close();
|
$pdf->Close();
|
||||||
//Ecriture du pdf
|
|
||||||
$pdf->Output($file);
|
$pdf->Output($file);
|
||||||
|
|
||||||
$langs->setPhpLang(); // On restaure langue session
|
$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"));
|
$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;
|
global $user,$conf,$langs;
|
||||||
|
|
||||||
@ -129,8 +135,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
|
|||||||
|
|
||||||
if ($conf->expedition->dir_output)
|
if ($conf->expedition->dir_output)
|
||||||
{
|
{
|
||||||
$this->expe = $objExpe;
|
$this->expe = $obj;
|
||||||
$this->expe->fetch_commande();
|
|
||||||
|
|
||||||
// Définition de $dir et $file
|
// Définition de $dir et $file
|
||||||
if ($this->expe->specimen)
|
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->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
|
$langs->setPhpLang(); // On restaure langue session
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@ -2233,7 +2233,7 @@ class Facture extends CommonObject
|
|||||||
$this->cond_reglement_code = 'RECEP';
|
$this->cond_reglement_code = 'RECEP';
|
||||||
$this->mode_reglement_code = 'CHQ';
|
$this->mode_reglement_code = 'CHQ';
|
||||||
$this->note_public='SPECIMEN';
|
$this->note_public='SPECIMEN';
|
||||||
$nbp = rand(1, 9);
|
$nbp = 5;
|
||||||
$xnbp = 0;
|
$xnbp = 0;
|
||||||
while ($xnbp < $nbp)
|
while ($xnbp < $nbp)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -573,5 +573,5 @@ DeliveriesOrderAbility=Prise en charge des bons de r
|
|||||||
ActivateFCKeditor=Activer FCKeditor pour :
|
ActivateFCKeditor=Activer FCKeditor pour :
|
||||||
FCKeditorForCompany=Création/édition WYSIWIG des descriptions et notes des tiers
|
FCKeditorForCompany=Création/édition WYSIWIG des descriptions et notes des tiers
|
||||||
FCKeditorForProductDescription=Création/édition WYSIWIG des notes des produits/services
|
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
|
FCKeditorForMailing=Création/édition WYSIWIG des mailings
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user