forked from Wavyzz/dolibarr
Merge remote-tracking branch 'Upstream/develop' into develop-loan
This commit is contained in:
@@ -192,10 +192,12 @@ abstract class DolibarrModules
|
||||
* Enables a module.
|
||||
* Inserts all informations into database
|
||||
*
|
||||
* @param string[] $array_sql SQL requests to be executed when enabling module
|
||||
* @param string $options String with options when disabling module ('newboxdefonly|noboxes')
|
||||
* @param array $array_sql SQL requests to be executed when enabling module
|
||||
* @param string $options String with options when disabling module:
|
||||
* 'noboxes' = Do not insert boxes
|
||||
* 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
|
||||
*
|
||||
* @return int 1 if OK, 0 if KO
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function _init($array_sql, $options='')
|
||||
{
|
||||
@@ -279,7 +281,8 @@ abstract class DolibarrModules
|
||||
* Disable function. Deletes the module constant and boxes from the database.
|
||||
*
|
||||
* @param string[] $array_sql SQL requests to be executed when module is disabled
|
||||
* @param string $options Options when disabling module ('newboxdefonly|noboxes')
|
||||
* @param string $options Options when disabling module:
|
||||
* 'newboxdefonly|noboxes' = We don't remove boxes.
|
||||
*
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
@@ -344,7 +347,8 @@ abstract class DolibarrModules
|
||||
|
||||
|
||||
/**
|
||||
* Gives the translated module name if translation exists in admin.lang or the default module name.
|
||||
* Gives the translated module name if translation exists in admin.lang or into language files of module.
|
||||
* Otherwise return the module key name.
|
||||
*
|
||||
* @return string Translated module name
|
||||
*/
|
||||
@@ -359,9 +363,16 @@ abstract class DolibarrModules
|
||||
return $langs->trans("Module".$this->numero."Name");
|
||||
}
|
||||
else
|
||||
{
|
||||
// If module name translation using it's unique id does not exists, we take its name
|
||||
return $this->name;
|
||||
{
|
||||
// If module name translation using it's unique id does not exists, we take use its name to find translation
|
||||
if (is_array($this->langfiles))
|
||||
{
|
||||
foreach($this->langfiles as $val)
|
||||
{
|
||||
if ($val) $langs->load($val);
|
||||
}
|
||||
}
|
||||
return $langs->trans($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,9 +393,16 @@ abstract class DolibarrModules
|
||||
return $langs->trans("Module".$this->numero."Desc");
|
||||
}
|
||||
else
|
||||
{
|
||||
// If module description translation using it's unique id does not exists, we take its description
|
||||
return $this->description;
|
||||
{
|
||||
// If module description translation using it's unique id does not exists, we take use its name to find translation
|
||||
if (is_array($this->langfiles))
|
||||
{
|
||||
foreach($this->langfiles as $val)
|
||||
{
|
||||
if ($val) $langs->load($val);
|
||||
}
|
||||
}
|
||||
return $langs->trans($this->description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,11 +419,17 @@ abstract class DolibarrModules
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
||||
elseif ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
||||
elseif ($this->version == 'dolibarr') return DOL_VERSION;
|
||||
elseif ($this->version) return $this->version;
|
||||
else return $langs->trans("VersionUnknown");
|
||||
$ret='';
|
||||
|
||||
$newversion=preg_replace('/_deprecated/','',$this->version);
|
||||
if ($newversion == 'experimental') $ret=$langs->trans("VersionExperimental");
|
||||
elseif ($newversion == 'development') $ret=$langs->trans("VersionDevelopment");
|
||||
elseif ($newversion == 'dolibarr') $ret=DOL_VERSION;
|
||||
elseif ($newversion) $ret=$newversion;
|
||||
else $ret=$langs->trans("VersionUnknown");
|
||||
|
||||
if (preg_match('/_deprecated/',$this->version)) $ret.=' ('.$langs->trans("Deprecated").')';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -416,7 +440,7 @@ abstract class DolibarrModules
|
||||
*/
|
||||
function isCoreOrExternalModule()
|
||||
{
|
||||
if ($this->version == 'dolibarr') return 'core';
|
||||
if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') return 'core';
|
||||
if (! empty($this->version) && ! in_array($this->version,array('experimental','development'))) return 'external';
|
||||
if (! empty($this->editor_name) || ! empty($this->editor_web)) return 'external';
|
||||
return 'unknown';
|
||||
@@ -868,6 +892,8 @@ abstract class DolibarrModules
|
||||
|
||||
$err=0;
|
||||
|
||||
if (empty($this->const)) return 0;
|
||||
|
||||
foreach ($this->const as $key => $value)
|
||||
{
|
||||
$name = $this->const[$key][0];
|
||||
@@ -935,6 +961,8 @@ abstract class DolibarrModules
|
||||
|
||||
$err=0;
|
||||
|
||||
if (empty($this->const)) return 0;
|
||||
|
||||
foreach ($this->const as $key => $value)
|
||||
{
|
||||
$name = $this->const[$key][0];
|
||||
|
||||
@@ -127,7 +127,7 @@ class CommActionRapport
|
||||
$hookmanager=new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
$parameters=array('file'=>$file, 'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
|
||||
}
|
||||
}
|
||||
|
||||
$_file = $dir . "/bordereau-".$number.".pdf";
|
||||
$file = $dir . "/bordereau-".$number.".pdf";
|
||||
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
@@ -120,7 +120,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
|
||||
$hookmanager=new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
$parameters=array('file'=>$file, 'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
@@ -177,7 +177,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
|
||||
|
||||
$pdf->Close();
|
||||
|
||||
$pdf->Output($_file,'F');
|
||||
$pdf->Output($file,'F');
|
||||
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
@@ -191,7 +191,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
|
||||
$reshook=$hookmanager->executeHooks('adterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($_file, octdec($conf->global->MAIN_UMASK));
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
return 1; // Pas d'erreur
|
||||
|
||||
@@ -154,6 +154,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$outputlangs->load("orders");
|
||||
$outputlangs->load("deliveries");
|
||||
|
||||
$nblignes = count($object->lines);
|
||||
|
||||
if ($conf->commande->dir_output)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
@@ -195,8 +197,6 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$nblignes = count($object->lines);
|
||||
|
||||
// Create pdf instance
|
||||
$pdf=pdf_getInstance($this->format);
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
|
||||
@@ -328,6 +328,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
//print $pageposafter.'-'.$pageposbefore;exit;
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
|
||||
$pageposafter=$pdf->getPage();
|
||||
$posyafter=$pdf->GetY();
|
||||
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
|
||||
{
|
||||
@@ -511,11 +512,6 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->Output($file,'F');
|
||||
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager=new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
@@ -797,7 +793,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
//{
|
||||
foreach( $this->localtax1 as $localtax_type => $localtax_rate )
|
||||
{
|
||||
if (in_array((string) $localtax_type, array('1','3','5','7'))) continue;
|
||||
if (in_array((string) $localtax_type, array('1','3','5'))) continue;
|
||||
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||
{
|
||||
if ($tvakey!=0) // On affiche pas taux 0
|
||||
@@ -828,7 +824,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
//{
|
||||
foreach( $this->localtax2 as $localtax_type => $localtax_rate )
|
||||
{
|
||||
if (in_array((string) $localtax_type, array('1','3','5','7'))) continue;
|
||||
if (in_array((string) $localtax_type, array('1','3','5'))) continue;
|
||||
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||
{
|
||||
if ($tvakey!=0) // On affiche pas taux 0
|
||||
@@ -1188,7 +1184,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
if ($showaddress)
|
||||
{
|
||||
// Sender properties
|
||||
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
|
||||
@@ -1145,7 +1145,7 @@ class pdf_proforma extends ModelePDFCommandes
|
||||
if ($showaddress)
|
||||
{
|
||||
// Sender properties
|
||||
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
|
||||
@@ -53,6 +53,18 @@ class pdf_strato extends ModelePDFContract
|
||||
var $marge_haute;
|
||||
var $marge_basse;
|
||||
|
||||
/**
|
||||
* Issuer
|
||||
* @var Societe
|
||||
*/
|
||||
public $emetteur;
|
||||
|
||||
/**
|
||||
* Recipient
|
||||
* @var Societe
|
||||
*/
|
||||
public $recipient;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -227,29 +239,9 @@ class pdf_strato extends ModelePDFContract
|
||||
|
||||
$iniY = $tab_top + 7;
|
||||
$curY = $tab_top + 7;
|
||||
$nexY = $tab_top + 7;
|
||||
$nexY = $tab_top + 2;
|
||||
|
||||
$pdf->SetXY($this->marge_gauche, $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->SetFont('', '', $default_font_size - 1);
|
||||
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->SetXY($this->marge_gauche, $tab_top + 8);
|
||||
$text=$object->description;
|
||||
if ($object->duree > 0)
|
||||
{
|
||||
$totaltime=convertSecondToTime($object->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
|
||||
$text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
|
||||
}
|
||||
$desc=dol_htmlentitiesbr($text,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->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also.
|
||||
|
||||
@@ -273,7 +265,20 @@ class pdf_strato extends ModelePDFContract
|
||||
$pageposbefore=$pdf->getPage();
|
||||
|
||||
// Description of product line
|
||||
$txt='<strong>'.dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true)." - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration),1,$outputlangs->charset_output).'</strong>';
|
||||
|
||||
if ($objectligne->datei) {
|
||||
$datei = dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
|
||||
} else {
|
||||
$datei = $langs->trans("Unknown");
|
||||
}
|
||||
|
||||
if ($objectligne->duration) {
|
||||
$durationi = convertSecondToTime($objectligne->duration);
|
||||
} else {
|
||||
$durationi = $langs->trans("Unknown");
|
||||
}
|
||||
|
||||
$txt='<strong>'.dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".$datei." - ".$outputlangs->transnoentities("Duration")." : ".$durationi,1,$outputlangs->charset_output).'</strong>';
|
||||
$desc=dol_htmlentitiesbr($objectligne->desc,1);
|
||||
|
||||
$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0);
|
||||
@@ -521,7 +526,7 @@ class pdf_strato extends ModelePDFContract
|
||||
$posy+=4;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->datec,"day",false,$outputlangs,true), '', 'R');
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_creation,"day",false,$outputlangs,true), '', 'R');
|
||||
|
||||
if ($object->client->code_client)
|
||||
{
|
||||
@@ -543,7 +548,7 @@ class pdf_strato extends ModelePDFContract
|
||||
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
|
||||
}
|
||||
|
||||
$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
@@ -581,17 +586,17 @@ class pdf_strato extends ModelePDFContract
|
||||
$result=$object->fetch_contact($arrayidcontact[0]);
|
||||
}
|
||||
|
||||
$this->recipient = $object->client;
|
||||
|
||||
// Recipient name
|
||||
if (! empty($usecontact))
|
||||
{
|
||||
if (! empty($usecontact)) {
|
||||
// On peut utiliser le nom de la societe du contact
|
||||
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
|
||||
else $socname = $object->client->name;
|
||||
$this->recipient->name=$outputlangs->convToOutputCharset($socname);
|
||||
$this->recipient->name = $outputlangs->convToOutputCharset($socname);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->recipient->name=$outputlangs->convToOutputCharset($object->client->name);
|
||||
else {
|
||||
$this->recipient->name = $outputlangs->convToOutputCharset($object->client->name);
|
||||
}
|
||||
|
||||
$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, (isset($object->contact)?$object->contact:''), $usecontact, 'target');
|
||||
|
||||
@@ -157,8 +157,8 @@
|
||||
<table border="0" bgcolor="#ffffff" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td width="160" height="100" valign="top">
|
||||
<center>__Date__ & __Signature__</center>
|
||||
<center>__NOW__</center>
|
||||
<div class="center">__Date__ & __Signature__</div>
|
||||
<div class="center">__NOW__</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -539,7 +539,7 @@ class pdf_merou extends ModelePdfExpedition
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
// Sender properties
|
||||
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
$pdf->SetFont('','', $default_font_size - 3);
|
||||
$pdf->SetXY($blSocX,$blSocY+4);
|
||||
@@ -557,10 +557,16 @@ class pdf_merou extends ModelePdfExpedition
|
||||
|
||||
// Date Expedition
|
||||
$Yoff = $Yoff+7;
|
||||
$pdf->SetXY($blSocX-80,$blSocY+17);
|
||||
|
||||
$pdf->SetFont('','B', $default_font_size - 2);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDelivery")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L');
|
||||
|
||||
$pdf->SetXY($blSocX-80,$blSocY+20);
|
||||
$pdf->SetFont('','B', $default_font_size - 2);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L');
|
||||
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L');
|
||||
|
||||
// Deliverer
|
||||
$pdf->SetXY($blSocX-80,$blSocY+23);
|
||||
@@ -576,14 +582,18 @@ class pdf_merou extends ModelePdfExpedition
|
||||
{
|
||||
// Get code using getLabelFromKey
|
||||
$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
|
||||
$label=$outputlangs->trans("SendingMethod".strtoupper($code))." :";
|
||||
}
|
||||
else
|
||||
{
|
||||
$label=$outputlangs->transnoentities("Deliverer");
|
||||
}
|
||||
|
||||
$pdf->writeHTMLCell(50, 8, '', '', $label." ".$object->tracking_url, '', 'L');
|
||||
$label='';
|
||||
$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
|
||||
//var_dump($object->tracking_url != $object->tracking_number);exit;
|
||||
if ($object->tracking_url != $object->tracking_number)
|
||||
{
|
||||
$label.=" : ";
|
||||
$label.=$object->tracking_url;
|
||||
}
|
||||
$pdf->SetFont('','B', $default_font_size - 2);
|
||||
$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -191,11 +191,17 @@ class pdf_rouget extends ModelePdfExpedition
|
||||
$tab_height = 130;
|
||||
$tab_height_newpage = 150;
|
||||
|
||||
if (! empty($object->note_public) || (! empty($object->tracking_number) && ! empty($object->shipping_method_id)))
|
||||
if (! empty($object->note_public) || ! empty($object->tracking_number))
|
||||
{
|
||||
$tab_top = 88;
|
||||
$tab_top_alt = $tab_top;
|
||||
|
||||
$pdf->SetFont('','B', $default_font_size - 2);
|
||||
$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
|
||||
|
||||
$tab_top_alt = $pdf->GetY();
|
||||
//$tab_top_alt += 1;
|
||||
|
||||
// Tracking number
|
||||
if (! empty($object->tracking_number))
|
||||
{
|
||||
@@ -206,17 +212,24 @@ class pdf_rouget extends ModelePdfExpedition
|
||||
{
|
||||
// Get code using getLabelFromKey
|
||||
$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
|
||||
$label=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
|
||||
$label.=$outputlangs->trans("SendingMethod".strtoupper($code))." :";
|
||||
$label='';
|
||||
if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
|
||||
$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
|
||||
//var_dump($object->tracking_url != $object->tracking_number);exit;
|
||||
if ($object->tracking_url != $object->tracking_number)
|
||||
{
|
||||
$label.=" : ";
|
||||
$label.=$object->tracking_url;
|
||||
}
|
||||
$pdf->SetFont('','B', $default_font_size - 2);
|
||||
$pdf->writeHTMLCell(60, 7, $this->posxdesc-1, $tab_top-1, $label." ".$object->tracking_url, 0, 1, false, true, 'L');
|
||||
$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
|
||||
|
||||
$tab_top_alt += 7;
|
||||
$tab_top_alt = $pdf->GetY();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Affiche notes
|
||||
// Notes
|
||||
if (! empty($object->note_public))
|
||||
{
|
||||
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
|
||||
@@ -531,7 +544,7 @@ class pdf_rouget extends ModelePdfExpedition
|
||||
$posy+=4;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_creation,"daytext",false,$outputlangs,true), '', 'R');
|
||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true), '', 'R');
|
||||
|
||||
if (! empty($object->client->code_client))
|
||||
{
|
||||
@@ -587,7 +600,7 @@ class pdf_rouget extends ModelePdfExpedition
|
||||
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
|
||||
}
|
||||
|
||||
$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posx=$this->marge_gauche;
|
||||
|
||||
754
htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
Executable file
754
htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
Executable file
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
|
||||
* \ingroup expensereport
|
||||
* \brief File of class to generate invoices from standard model
|
||||
*/
|
||||
|
||||
dol_include_once("/expensereport/core/modules/expensereport/modules_expensereport.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Classe permettant de generer les factures au modele Crabe
|
||||
*/
|
||||
class pdf_ extends ModeleExpenseReport
|
||||
{
|
||||
var $emetteur; // Objet societe qui emet
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $conf,$langs,$mysoc;
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("trips");
|
||||
$langs->load("project");
|
||||
$langs->load("expensereport@expensereport");
|
||||
|
||||
$this->db = $db;
|
||||
$this->name = "";
|
||||
$this->description = $langs->trans('PDFDescription');
|
||||
|
||||
// Dimension page pour format A4
|
||||
$this->type = 'pdf';
|
||||
$formatarray=pdf_getFormat();
|
||||
$this->page_largeur = $formatarray['width'];
|
||||
$this->page_hauteur = $formatarray['height'];
|
||||
$this->format = array($this->page_largeur,$this->page_hauteur);
|
||||
$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
|
||||
$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
|
||||
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
|
||||
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
|
||||
|
||||
$this->option_logo = 1; // Affiche logo
|
||||
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
|
||||
$this->option_modereg = 1; // Affiche mode reglement
|
||||
$this->option_condreg = 1; // Affiche conditions reglement
|
||||
$this->option_codeproduitservice = 1; // Affiche code produit-service
|
||||
$this->option_multilang = 1; // Dispo en plusieurs langues
|
||||
$this->option_escompte = 1; // Affiche si il y a eu escompte
|
||||
$this->option_credit_note = 1; // Support credit notes
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
|
||||
|
||||
$this->franchise=!$mysoc->tva_assuj;
|
||||
|
||||
// Get source company
|
||||
$this->emetteur=$mysoc;
|
||||
if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
|
||||
|
||||
// Defini position des colonnes
|
||||
// Defini position des colonnes
|
||||
$this->posxpiece=$this->marge_gauche+1;
|
||||
$this->posxdesc=20;
|
||||
$this->posxdate=85;
|
||||
$this->posxtype=105;
|
||||
$this->posxprojet=125;
|
||||
$this->posxtva=145;
|
||||
$this->posxup=158;
|
||||
$this->posxqty=170;
|
||||
$this->postotalttc=176;
|
||||
if ($this->page_largeur < 210) // To work with US executive format
|
||||
{
|
||||
$this->posxdate-=20;
|
||||
$this->posxtype-=20;
|
||||
$this->posxprojet-=20;
|
||||
$this->posxtva-=20;
|
||||
$this->posxup-=20;
|
||||
$this->posxqty-=20;
|
||||
$this->postotalttc-=20;
|
||||
}
|
||||
|
||||
$this->tva=array();
|
||||
$this->localtax1=array();
|
||||
$this->localtax2=array();
|
||||
$this->atleastoneratenotnull=0;
|
||||
$this->atleastonediscount=0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to build pdf onto disk
|
||||
*
|
||||
* @param Object $object Object to generate
|
||||
* @param Translate $outputlangs Lang output object
|
||||
* @param string $srctemplatepath Full path of source filename for generator using a template file
|
||||
* @param int $hidedetails Do not show line details
|
||||
* @param int $hidedesc Do not show desc
|
||||
* @param int $hideref Do not show ref
|
||||
*/
|
||||
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
|
||||
{
|
||||
global $user,$langs,$conf,$mysoc,$db,$hookmanager;
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
|
||||
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
|
||||
|
||||
|
||||
// Hack to use expensereport dir
|
||||
$rootfordata = DOL_DATA_ROOT;
|
||||
$rootforuser = DOL_DATA_ROOT;
|
||||
// If multicompany module is enabled, we redefine the root of data
|
||||
//if (! empty($this->multicompany->enabled) && ! empty($this->entity) && $this->entity > 1)
|
||||
//{
|
||||
// $rootfordata.='/'.$this->entity;
|
||||
//}
|
||||
$conf->expensereport->dir_output = $rootfordata.'/expensereport';
|
||||
$conf->expensereport_->dir_output = $rootfordata.'/expensereport';
|
||||
|
||||
|
||||
$outputlangs->load("main");
|
||||
$outputlangs->load("dict");
|
||||
$outputlangs->load("trips");
|
||||
$outputlangs->load("project");
|
||||
$outputlangs->load("expensereport@expensereport");
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
if ($conf->expensereport_->dir_output)
|
||||
{
|
||||
// Definition de l'objet $object (pour compatibilite ascendante)
|
||||
if (! is_object($object))
|
||||
{
|
||||
$id = $object;
|
||||
$object = new ExpenseReport($db);
|
||||
$ret=$object->fetch($id,$user);
|
||||
}
|
||||
|
||||
$objectref = dol_sanitizeFileName($object->ref_number);
|
||||
$dir = $conf->expensereport_->dir_output . "/" . $objectref;
|
||||
$file = $dir . "/" . $objectref . ".pdf";
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
if (dol_mkdir($dir) < 0)
|
||||
{
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($object->lignes) && ! isset($object->lines)) $object->lines=$object->lignes;
|
||||
|
||||
if (file_exists($dir))
|
||||
{
|
||||
$nblignes = count($object->lines);
|
||||
|
||||
// Create pdf instance
|
||||
$pdf=pdf_getInstance($this->format);
|
||||
|
||||
if (class_exists('TCPDF'))
|
||||
{
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
}
|
||||
$pdf->SetFont(pdf_getPDFFont($outputlangs));
|
||||
// Set path to the background PDF File
|
||||
if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
|
||||
{
|
||||
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
|
||||
$tplidx = $pdf->importPage(1);
|
||||
}
|
||||
|
||||
$pdf->Open();
|
||||
$pagenb=0;
|
||||
$pdf->SetDrawColor(128,128,128);
|
||||
|
||||
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref_number));
|
||||
$pdf->SetSubject($outputlangs->transnoentities("Trips"));
|
||||
$pdf->SetCreator("");
|
||||
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
|
||||
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref_number)." ".$outputlangs->transnoentities("Trips"));
|
||||
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
||||
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
$pdf->SetAutoPageBreak(1,0);
|
||||
|
||||
// Positionne $this->atleastonediscount si on a au moins une remise
|
||||
for ($i = 0 ; $i < $nblignes ; $i++)
|
||||
{
|
||||
if ($object->lines[$i]->remise_percent)
|
||||
{
|
||||
$this->atleastonediscount++;
|
||||
}
|
||||
}
|
||||
|
||||
// New page
|
||||
$pdf->AddPage();
|
||||
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
$pagenb++;
|
||||
$this->_pagehead($pdf, $object, 1, $outputlangs);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$tab_top = 95;
|
||||
$tab_top_newpage = 95;
|
||||
$tab_height = 110;
|
||||
$tab_height_newpage = 110;
|
||||
|
||||
// Affiche notes
|
||||
if (! empty($object->note))
|
||||
{
|
||||
$tab_top = 93;
|
||||
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
$height_note=$nexY-$tab_top;
|
||||
|
||||
// Rect prend une longueur en 3eme param
|
||||
$pdf->SetDrawColor(192,192,192);
|
||||
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
|
||||
|
||||
$tab_height = $tab_height - $height_note;
|
||||
$tab_top = $nexY+6;
|
||||
}
|
||||
else
|
||||
{
|
||||
$height_note=0;
|
||||
}
|
||||
|
||||
$iniY = $tab_top + 7;
|
||||
$curY = $tab_top + 7;
|
||||
$nexY = $tab_top + 7;
|
||||
|
||||
// Loop on each lines
|
||||
for ($i = 0 ; $i < $nblignes ; $i++)
|
||||
{
|
||||
$curY = $nexY;
|
||||
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$piece_comptable = $i +1;
|
||||
|
||||
// Piece comptable
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-1, 3, $this->posxpiece-1, $curY, $piece_comptable, 0, 1);
|
||||
|
||||
// Comments
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY ($this->posxcomment, $curY);
|
||||
$pdf->writeHTMLCell($this->posxdate-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $object->lignes[$i]->comments, 0, 1);
|
||||
|
||||
//nexY
|
||||
$nexY = $pdf->GetY();
|
||||
|
||||
// Date
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY ($this->posxdate, $curY);
|
||||
$pdf->MultiCell($this->posxtype-$this->posxdate-1, 3,dol_print_date($object->lignes[$i]->date,"day",false,$outpulangs), 0, 'C');
|
||||
|
||||
// Type
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY ($this->posxtype, $curY);
|
||||
$pdf->MultiCell($this->posxprojet-$this->posxtype-1, 3,$outputlangs->transnoentities($object->lignes[$i]->type_fees_code), 0, 'C');
|
||||
|
||||
// Projet
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY ($this->posxprojet, $curY);
|
||||
$pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lignes[$i]->projet_ref, 0, 'C');
|
||||
|
||||
// TVA
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY ($this->posxtva, $curY);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,vatrate($object->lignes[$i]->tva_taux,true), 0, 'R');
|
||||
|
||||
// UP
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY ($this->posxup, $curY);
|
||||
$pdf->MultiCell($this->posxqty-$this->posxup-1, 3,price($object->lignes[$i]->value_unit), 0, 'R');
|
||||
|
||||
// QTY
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY ($this->posxqty, $curY);
|
||||
$pdf->MultiCell($this->postotalttc-$this->posxqty, 3,$object->lignes[$i]->qty, 0, 'C');
|
||||
|
||||
// TotalTTC
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY ($this->postotalttc-2, $curY);
|
||||
$pdf->MultiCell(26, 3,price($object->lignes[$i]->total_ttc), 0, 'R');
|
||||
|
||||
$nexY+=5;
|
||||
|
||||
// Cherche nombre de lignes a venir pour savoir si place suffisante
|
||||
if ($i < ($nblignes - 1)) // If it's not last line
|
||||
{
|
||||
//on recupere la description du produit suivant
|
||||
$follow_descproduitservice = $object->lines[$i+1]->desc;
|
||||
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
|
||||
$nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4;
|
||||
// Et si on affiche dates de validite, on ajoute encore une ligne
|
||||
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
|
||||
{
|
||||
$nblineFollowDesc += 4;
|
||||
}
|
||||
}
|
||||
else // If it's last line
|
||||
{
|
||||
$nblineFollowDesc = 0;
|
||||
}
|
||||
|
||||
// Test if a new page is required
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$tab_top_in_current_page=$tab_top;
|
||||
$tab_height_in_current_page=$tab_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tab_top_in_current_page=$tab_top_newpage;
|
||||
$tab_height_in_current_page=$tab_height_newpage;
|
||||
}
|
||||
if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1))
|
||||
{
|
||||
if ($pagenb == 1):
|
||||
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
|
||||
$nexY=$tab_top + $tab_height + 1;
|
||||
else:
|
||||
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
|
||||
$nexY=$tab_top_newpage + $tab_height_newpage + 1;
|
||||
endif;
|
||||
|
||||
$this->_pagefoot($pdf,$object,$outputlangs);
|
||||
|
||||
// New page
|
||||
$pdf->AddPage();
|
||||
$pagenb++;
|
||||
$this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$nexY = $tab_top_newpage + 7;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show square
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
|
||||
$bottomlasttab=$tab_top + $tab_height + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
|
||||
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
|
||||
}
|
||||
|
||||
// Affiche zone totaux
|
||||
$posy=$bottomlasttab+5;//$nexY+95;
|
||||
$pdf->SetXY(120, $posy);
|
||||
$pdf->MultiCell(50, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L');
|
||||
$pdf->SetXY (170, $posy);
|
||||
$pdf->MultiCell(30, 5, price($object->total_ht), 1, 'R');
|
||||
$pdf->SetFillColor(248,248,248);
|
||||
|
||||
$posy+=5;
|
||||
$pdf->SetXY (120, $posy);
|
||||
$pdf->SetFont('','B', 10);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(50, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L');
|
||||
$pdf->SetXY (170, $posy);
|
||||
$pdf->MultiCell(30, 5, price($object->total_ttc),1, 'R');
|
||||
|
||||
// Pied de page
|
||||
$this->_pagefoot($pdf,$object,$outputlangs);
|
||||
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
|
||||
|
||||
$pdf->Close();
|
||||
|
||||
$pdf->Output($file,'F');
|
||||
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager=new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans("ErrorConstantNotDefined","DEPLACEMENT_OUTPUTDIR");
|
||||
return 0;
|
||||
}
|
||||
$this->error=$langs->trans("ErrorUnknown");
|
||||
return 0; // Erreur par defaut
|
||||
}
|
||||
|
||||
/**
|
||||
* Show top header of page.
|
||||
*
|
||||
* @param PDF $pdf Object PDF
|
||||
* @param Object $object Object to show
|
||||
* @param int $showaddress 0=no, 1=yes
|
||||
* @param Translate $outputlangs Object lang for output
|
||||
* @return void
|
||||
*/
|
||||
function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
|
||||
{
|
||||
global $conf,$langs,$hookmanager;
|
||||
|
||||
$outputlangs->load("main");
|
||||
$outputlangs->load("trips");
|
||||
$outputlangs->load("companies");
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
/*
|
||||
// ajout du fondu vert en bas de page à droite
|
||||
$image_fondue = $conf->mycompany->dir_output.'/fondu_vert_.jpg';
|
||||
$pdf->Image($image_fondue,20,107,200,190);
|
||||
|
||||
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
|
||||
*/
|
||||
|
||||
// Filligrane brouillon
|
||||
if($object->fk_c_expensereport_statuts==1)
|
||||
{
|
||||
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',"' - PREVIEW ONLY");
|
||||
}
|
||||
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->SetFont('','B', $default_font_size + 3);
|
||||
|
||||
$posy=$this->marge_haute;
|
||||
$posx=$this->page_largeur-$this->marge_droite-100;
|
||||
|
||||
$pdf->SetXY($this->marge_gauche,$posy);
|
||||
|
||||
// Logo
|
||||
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
|
||||
if ($this->emetteur->logo)
|
||||
{
|
||||
if (is_readable($logo))
|
||||
{
|
||||
$height=pdf_getHeightForLogo($logo);
|
||||
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->SetTextColor(200,0,0);
|
||||
$pdf->SetFont('','B', $default_font_size -2);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$text=$this->emetteur->name;
|
||||
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
|
||||
}
|
||||
|
||||
$pdf->SetFont('','B', $default_font_size + 6);
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetTextColor(255,255,255);
|
||||
$pdf->SetFillColor(193,219,62);
|
||||
$ref_text = explode($conf->global->NDF_EXPLODE_CHAR,$object->ref_number);
|
||||
$ref_text = substr($ref_text[1],3,$conf->global->NDF_NUM_CAR_REF);
|
||||
$pdf->MultiCell(110,6,"Note de frais ".$ref_text, 0, 'L', 1);
|
||||
|
||||
$pdf->SetFont('','', $default_font_size -1);
|
||||
|
||||
// Réf complète
|
||||
$posy+=8;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref_number, '', 'L');
|
||||
|
||||
// Date début période
|
||||
$posy+=5;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?$object->date_debut:dol_print_date($object->date_debut,"day",false,$outpulangs)), '', 'L');
|
||||
|
||||
// Date fin période
|
||||
$posy+=5;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outpulangs):''), '', 'L');
|
||||
|
||||
// Statut NDF
|
||||
$posy+=7;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetFont('','B',20);
|
||||
$pdf->SetTextColor(111,81,124);
|
||||
if(preg_match("#Pay#",$object->libelle_statut) && !preg_match("#A P#",$object->libelle_statut)):
|
||||
$pdf->MultiCell(100, 3,$outputlangs->convToOutputCharset("Payée"), '', 'L');
|
||||
elseif(preg_match("#Annul#",$object->libelle_statut)):
|
||||
$pdf->MultiCell(100, 3,$outputlangs->convToOutputCharset("Annulée"), '', 'L');
|
||||
elseif(preg_match("#Refus#",$object->libelle_statut)):
|
||||
$pdf->MultiCell(100, 3,$outputlangs->convToOutputCharset("Refusée"), '', 'L');
|
||||
else:
|
||||
$pdf->MultiCell(100, 3,$object->libelle_statut, '', 'L');
|
||||
endif;
|
||||
|
||||
// Sender properties
|
||||
$carac_emetteur = '';
|
||||
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address);
|
||||
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town);
|
||||
$carac_emetteur .= "\n";
|
||||
// Tel
|
||||
if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
|
||||
// Fax
|
||||
if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
|
||||
// EMail
|
||||
if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email);
|
||||
// Web
|
||||
if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url);
|
||||
|
||||
// Show sender
|
||||
$posy=50;
|
||||
$posx=$this->marge_gauche;
|
||||
$hautcadre=40;
|
||||
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;
|
||||
|
||||
// Show sender frame
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetFont('','B', $default_font_size - 2);
|
||||
$pdf->SetXY($posx,$posy-5);
|
||||
$pdf->MultiCell(66,5, $outputlangs->transnoentities("TripSociete")." :",'','L');
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetFillColor(224,224,224);
|
||||
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
|
||||
// Show sender name
|
||||
$pdf->SetXY($posx+2,$posy+3);
|
||||
$pdf->SetFont('','B', $default_font_size);
|
||||
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
|
||||
|
||||
// Show sender information
|
||||
$pdf->SetXY($posx+2,$posy+8);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
|
||||
|
||||
// Show recipient
|
||||
$posy=50;
|
||||
$posx=100;
|
||||
|
||||
// Show recipient frame
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetFont('','B',8);
|
||||
$pdf->SetXY($posx,$posy-5);
|
||||
$pdf->MultiCell(80,5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L');
|
||||
$pdf->rect($posx, $posy, 100, $hautcadre);
|
||||
|
||||
// Informations for trip (dates and users workflow)
|
||||
$userfee=new User($this->db);
|
||||
$userfee->fetch($object->fk_user_author); $posy+=3;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->SetFont('','',10);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L');
|
||||
$posy+=5;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_SAVE")." : ".dol_print_date($object->date_create,"day",false,$outpulangs),0,'L');
|
||||
|
||||
if($object->fk_c_expensereport_statuts<3):
|
||||
$userfee=new User($this->db);
|
||||
$userfee->fetch($object->fk_user_validator); $posy+=6;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDATOR")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L');
|
||||
elseif($object->fk_c_expensereport_statuts==99):
|
||||
$userfee=new User($this->db);
|
||||
$userfee->fetch($object->fk_user_refuse); $posy+=6;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L');
|
||||
$posy+=5;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L');
|
||||
$posy+=5;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outpulangs),0,'L');
|
||||
elseif($object->fk_c_expensereport_statuts==4):
|
||||
$userfee=new User($this->db);
|
||||
$userfee->fetch($object->fk_user_cancel); $posy+=6;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L');
|
||||
$posy+=5;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L');
|
||||
$posy+=5;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outpulangs),0,'L');
|
||||
else:
|
||||
$userfee=new User($this->db);
|
||||
$userfee->fetch($object->fk_user_validator); $posy+=6;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L');
|
||||
$posy+=5;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_VALIDE")." : ".dol_print_date($object->date_valide,"day",false,$outpulangs),0,'L');
|
||||
endif;
|
||||
|
||||
if($object->fk_c_expensereport_statuts==6):
|
||||
$userfee=new User($this->db);
|
||||
$userfee->fetch($object->fk_user_paid); $posy+=6;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L');
|
||||
$posy+=5;
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outpulangs),0,'L');
|
||||
endif;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Affiche la grille des lignes de factures
|
||||
*
|
||||
* @param PDF $pdf Object PDF
|
||||
* @param int $tab_top Tab top
|
||||
* @param int $tab_height Tab height
|
||||
* @param int $nexY next y
|
||||
* @param Translate $outputlangs Output langs
|
||||
* @return void
|
||||
*/
|
||||
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
// Amount in (at tab_top - 1)
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetFont('','', $default_font_size - 2);
|
||||
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
|
||||
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4);
|
||||
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
|
||||
|
||||
$pdf->SetDrawColor(128,128,128);
|
||||
|
||||
// Rect prend une longueur en 3eme param
|
||||
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
|
||||
// line prend une position y en 3eme param
|
||||
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
|
||||
|
||||
$pdf->SetFont('','',8);
|
||||
|
||||
//Piece comptable
|
||||
$pdf->SetXY ($this->posxpiece-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxpiece-$this->posxpiece-1,1,$outputlangs->transnoentities("Piece"),'','L');
|
||||
|
||||
//Comments
|
||||
$pdf->line($this->posxdesc-1, $tab_top, $this->posxdesc-1, $tab_top + $tab_height);
|
||||
$pdf->SetXY ($this->posxdesc-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxdate-$this->posxdesc-1,1,$outputlangs->transnoentities("Description"),'','L');
|
||||
|
||||
//Date
|
||||
$pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height);
|
||||
$pdf->SetXY ($this->posxdate-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C');
|
||||
|
||||
//Type
|
||||
$pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height);
|
||||
$pdf->SetXY ($this->posxtype-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxprojet-$this->posxtype-1,2, $outputlangs->transnoentities("Type"),'','C');
|
||||
|
||||
// Projet
|
||||
$pdf->line($this->posxprojet-1, $tab_top, $this->posxprojet-1, $tab_top + $tab_height);
|
||||
$pdf->SetXY ($this->posxprojet-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C');
|
||||
|
||||
//TVA
|
||||
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
|
||||
$pdf->SetXY ($this->posxtva-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C');
|
||||
|
||||
//PU
|
||||
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
|
||||
$pdf->SetXY ($this->posxup-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PU"),'','C');
|
||||
|
||||
//QTY
|
||||
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
|
||||
$pdf->SetXY ($this->posxqty-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->postotalttc-$this->posxqty,2, $outputlangs->transnoentities("Q"),'','R');
|
||||
|
||||
//TOTALTTC
|
||||
$pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
|
||||
$pdf->SetXY ($this->postotalttc-4, $tab_top+1);
|
||||
$pdf->MultiCell(28,2, $outputlangs->transnoentities("TotalTTC"),'','R');
|
||||
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show footer of page. Need this->emetteur object
|
||||
*
|
||||
* @param PDF $pdf PDF
|
||||
* @param Object $object Object to show
|
||||
* @param Translate $outputlangs Object lang for output
|
||||
* @param int $hidefreetext 1=Hide free text
|
||||
* @return int Return height of bottom margin including footer text
|
||||
*/
|
||||
function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
|
||||
{
|
||||
return pdf_pagefoot($pdf,$outputlangs,'DEPLACEMENT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
110
htdocs/core/modules/expensereport/modules_expensereport.php
Executable file
110
htdocs/core/modules/expensereport/modules_expensereport.php
Executable file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Parent class for trips and expenses templates
|
||||
*/
|
||||
class ModeleExpenseReport extends CommonDocGenerator
|
||||
{
|
||||
var $error='';
|
||||
|
||||
|
||||
/**
|
||||
* Return list of active generation modules
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $maxfilenamelength Max length of value to show
|
||||
* @return array List of templates
|
||||
*/
|
||||
static function liste_modeles($db,$maxfilenamelength=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$type='expensereport';
|
||||
$liste=array();
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$liste=getListOfModels($db,$type,$maxfilenamelength);
|
||||
|
||||
return $liste;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function expensereport_pdf_create($db, $id, $message, $modele, $outputlangs)
|
||||
{
|
||||
global $conf,$langs;
|
||||
$langs->load("trips");
|
||||
|
||||
// Increase limit for PDF build
|
||||
$err=error_reporting();
|
||||
error_reporting(0);
|
||||
@set_time_limit(120);
|
||||
error_reporting($err);
|
||||
|
||||
$dir = dol_buildpath('/expensereport/core/modules/expensereport/');
|
||||
|
||||
// Positionne modele sur le nom du modele a utiliser
|
||||
if (! strlen($modele))
|
||||
{
|
||||
if ($conf->global->DEPLACEMENT_ADDON_PDF)
|
||||
{
|
||||
$modele = $conf->global->DEPLACEMENT_ADDON_PDF;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("Error_DEPLACEMENT_ADDON_PDF_NotDefined");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
if (file_exists($dir.$file))
|
||||
{
|
||||
$classname = "pdf_".$modele;
|
||||
require_once($dir.$file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
$obj->message = $message;
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
if ($obj->write_file($id, $outputlangs) > 0)
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
dol_print_error($db,"expensereport_pdf_create Error: ".$obj->error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.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
|
||||
@@ -56,7 +58,17 @@ class pdf_crabe extends ModelePDFFactures
|
||||
|
||||
var $emetteur; // Objet societe qui emet
|
||||
|
||||
/**
|
||||
* @var bool Situation invoice type
|
||||
*/
|
||||
public $situationinvoice;
|
||||
|
||||
/**
|
||||
* @var float X position for the situation progress column
|
||||
*/
|
||||
public $posxprogress;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -107,6 +119,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$this->posxup=126;
|
||||
$this->posxqty=145;
|
||||
$this->posxdiscount=162;
|
||||
$this->posxprogress=174; // Only displayed for situation invoices
|
||||
$this->postotalht=174;
|
||||
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
|
||||
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
|
||||
@@ -125,6 +138,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$this->localtax2=array();
|
||||
$this->atleastoneratenotnull=0;
|
||||
$this->atleastonediscount=0;
|
||||
$this->situationinvoice=False;
|
||||
}
|
||||
|
||||
|
||||
@@ -278,6 +292,18 @@ class pdf_crabe extends ModelePDFFactures
|
||||
//$this->postotalht;
|
||||
}
|
||||
|
||||
// Situation invoice handling
|
||||
if ($object->situation_cycle_ref)
|
||||
{
|
||||
$this->situationinvoice = True;
|
||||
$progress_width = 14;
|
||||
$this->posxtva -= $progress_width;
|
||||
$this->posxup -= $progress_width;
|
||||
$this->posxqty -= $progress_width;
|
||||
$this->posxdiscount -= $progress_width;
|
||||
$this->posxprogress -= $progress_width;
|
||||
}
|
||||
|
||||
// New page
|
||||
$pdf->AddPage();
|
||||
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
@@ -444,16 +470,30 @@ class pdf_crabe extends ModelePDFFactures
|
||||
{
|
||||
$pdf->SetXY($this->posxdiscount-2, $curY);
|
||||
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
|
||||
$pdf->MultiCell($this->posxprogress-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
|
||||
}
|
||||
|
||||
if ($this->situationinvoice)
|
||||
{
|
||||
// Situation progress
|
||||
$progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->SetXY($this->posxprogress, $curY);
|
||||
$pdf->MultiCell($this->postotalht-$this->posxprogress, 3, $progress, 0, 'R');
|
||||
}
|
||||
|
||||
// Total HT line
|
||||
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->SetXY($this->postotalht, $curY);
|
||||
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
|
||||
|
||||
|
||||
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
|
||||
$tvaligne=$object->lines[$i]->total_tva;
|
||||
$prev_progress = $object->lines[$i]->get_prev_progress();
|
||||
if ($prev_progress > 0) // Compute progress from previous situation
|
||||
{
|
||||
$tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
|
||||
} else {
|
||||
$tvaligne = $object->lines[$i]->total_tva;
|
||||
}
|
||||
$localtax1ligne=$object->lines[$i]->total_localtax1;
|
||||
$localtax2ligne=$object->lines[$i]->total_localtax2;
|
||||
$localtax1_rate=$object->lines[$i]->localtax1_tx;
|
||||
@@ -1434,7 +1474,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
if ($showaddress)
|
||||
{
|
||||
// Sender properties
|
||||
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
|
||||
@@ -96,7 +96,7 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
/**
|
||||
* Function to build pdf onto disk
|
||||
*
|
||||
* @param CommonObject $object Id of object to generate
|
||||
* @param Object $object Object to generate
|
||||
* @param Translate $outputlangs Lang output object
|
||||
* @param string $srctemplatepath Full path of source filename for generator using a template file
|
||||
* @param int $hidedetails Do not show line details
|
||||
@@ -106,7 +106,7 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
*/
|
||||
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
|
||||
{
|
||||
global $user,$langs,$conf,$mysoc;
|
||||
global $user,$langs,$conf,$mysoc,$db,$hookmanager;
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
|
||||
@@ -121,16 +121,24 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir = $conf->ficheinter->dir_output;
|
||||
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
|
||||
$file = $dir . "/" . $objectref . ".pdf";
|
||||
// Definition of $dir and $file
|
||||
if ($object->specimen)
|
||||
{
|
||||
$dir = $conf->ficheinter->dir_output;
|
||||
$file = $dir . "/SPECIMEN.pdf";
|
||||
}
|
||||
else
|
||||
{
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir = $conf->ficheinter->dir_output . "/" . $objectref;
|
||||
$file = $dir . "/" . $objectref . ".pdf";
|
||||
}
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
if (dol_mkdir($dir) < 0)
|
||||
{
|
||||
$this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -149,6 +157,9 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$nblignes = count($object->lines);
|
||||
|
||||
// Create pdf instance
|
||||
$pdf=pdf_getInstance($this->format);
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
|
||||
$heightforinfotot = 50; // Height reserved to output the info and total part
|
||||
@@ -196,12 +207,13 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
$tab_height_newpage = 150;
|
||||
|
||||
// Affiche notes
|
||||
if (! empty($object->note_public))
|
||||
$notetoshow=empty($object->note_public)?'':$object->note_public;
|
||||
if ($notetoshow)
|
||||
{
|
||||
$tab_top = 88;
|
||||
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
|
||||
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
$height_note=$nexY-$tab_top;
|
||||
|
||||
@@ -252,15 +264,17 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
$valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
|
||||
if ($valide > 0 || $object->specimen)
|
||||
{
|
||||
$curX = $this->posxdesc-1;
|
||||
$curY = $nexY;
|
||||
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$pdf->setTopMargin($tab_top_newpage);
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext/*+$heightforinfotot*/); // The only function to edit the bottom margin of current page to set it.
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
|
||||
$pageposbefore=$pdf->getPage();
|
||||
|
||||
// Description of product line
|
||||
$curX = $this->posxdesc-1;
|
||||
|
||||
// Description of product line
|
||||
$txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
|
||||
if ($objectligne->duration > 0)
|
||||
@@ -270,7 +284,34 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
$txt='<strong>'.dol_htmlentitiesbr($txt,1,$outputlangs->charset_output).'</strong>';
|
||||
$desc=dol_htmlentitiesbr($objectligne->desc,1);
|
||||
|
||||
$pdf->startTransaction();
|
||||
$pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt,$desc), 0, 1, 0);
|
||||
$pageposafter=$pdf->getPage();
|
||||
if ($pageposafter > $pageposbefore) // There is a pagebreak
|
||||
{
|
||||
$pdf->rollbackTransaction(true);
|
||||
$pageposafter=$pageposbefore;
|
||||
//print $pageposafter.'-'.$pageposbefore;exit;
|
||||
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
|
||||
$pdf->writeHTMLCell(0, 0, $curX, $curY, $txt.'<br>'.$desc, LR, 1, 0);
|
||||
$pageposafter=$pdf->getPage();
|
||||
$posyafter=$pdf->GetY();
|
||||
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
|
||||
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
|
||||
{
|
||||
if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
|
||||
{
|
||||
$pdf->AddPage('','',true);
|
||||
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
$pdf->setPage($pageposafter+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // No pagebreak
|
||||
{
|
||||
$pdf->commitTransaction();
|
||||
}
|
||||
|
||||
$nexY = $pdf->GetY();
|
||||
$pageposafter=$pdf->getPage();
|
||||
@@ -291,33 +332,34 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
$pdf->setPage($pagenb);
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1);
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
|
||||
}
|
||||
$this->_pagefoot($pdf,$object,$outputlangs,1);
|
||||
$pagenb++;
|
||||
$pdf->setPage($pagenb);
|
||||
$this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
|
||||
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
}
|
||||
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
|
||||
{
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext, 0, $outputlangs, 0, 1);
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext, 0, $outputlangs, 1, 1);
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
|
||||
}
|
||||
$this->_pagefoot($pdf,$object,$outputlangs,1);
|
||||
// New page
|
||||
$pdf->AddPage();
|
||||
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
|
||||
$pagenb++;
|
||||
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,13 +367,13 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
// Show square
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfreetext - $heightforfooter - 50, 0, $outputlangs, 0, 0);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfreetext - $heightforfooter - 50, 0, $outputlangs, 1, 0);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1;
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
|
||||
$this->_pagefoot($pdf,$object,$outputlangs);
|
||||
@@ -339,6 +381,13 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
|
||||
$pdf->Close();
|
||||
$pdf->Output($file,'F');
|
||||
|
||||
// Add pdfgeneration hook
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
@@ -522,7 +571,7 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
|
||||
}
|
||||
|
||||
$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
|
||||
@@ -599,7 +599,7 @@ class ImportCsv extends ModeleImports
|
||||
//var_dump($objimport->array_import_convertvalue); exit;
|
||||
|
||||
// Build SQL request
|
||||
if (empty($tablewithentity[$tablename]))
|
||||
if (empty($tablewithentity_cache[$tablename]))
|
||||
{
|
||||
$sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key';
|
||||
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias];
|
||||
|
||||
@@ -27,8 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
* \class MailingTargets
|
||||
* \brief Parent class of emailing target selectors modules
|
||||
* Parent class of emailing target selectors modules
|
||||
*/
|
||||
class MailingTargets // This can't be abstract as it is used for some method
|
||||
{
|
||||
|
||||
@@ -137,7 +137,7 @@ class pdf_standard
|
||||
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
|
||||
|
||||
// We are in a new page, then we must add a page
|
||||
if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) {
|
||||
if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
|
||||
$pdf->AddPage();
|
||||
}
|
||||
$this->_First=0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
@@ -19,14 +19,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file accountingex/core/modules/modAccounting.class.php
|
||||
* \file htdocs/core/modules/modAccounting.class.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Module to activate Accounting Expert module
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
||||
|
||||
/**
|
||||
* \class modAccountingExpert
|
||||
* \class modAccounting
|
||||
* \brief Description and activation class for module accounting expert
|
||||
*/
|
||||
class modAccounting extends DolibarrModules
|
||||
@@ -68,7 +68,7 @@ class modAccounting extends DolibarrModules
|
||||
$this->depends = array("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled
|
||||
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
||||
$this->conflictwith = array("modComptabilite"); // List of modules are in conflict with this module
|
||||
$this->phpmin = array(5, 2); // Minimum version of PHP required by module
|
||||
$this->phpmin = array(5, 3); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(3, 6); // Minimum version of Dolibarr required by module
|
||||
$this->langfiles = array("accountancy");
|
||||
|
||||
@@ -87,7 +87,7 @@ class modAccounting extends DolibarrModules
|
||||
"With this constants on, bank account number is always required"
|
||||
);
|
||||
$this->const[1] = array(
|
||||
"ACCOUNTING_SEPARATORCSV",
|
||||
"ACCOUNTING_EXPORT_SEPARATORCSV",
|
||||
"string",
|
||||
","
|
||||
);
|
||||
@@ -112,60 +112,85 @@ class modAccounting extends DolibarrModules
|
||||
"SOC"
|
||||
);
|
||||
$this->const[6] = array(
|
||||
"ACCOUNTING_CASH_JOURNAL",
|
||||
"chaine",
|
||||
"CAI"
|
||||
);
|
||||
$this->const[7] = array(
|
||||
"ACCOUNTING_MISCELLANEOUS_JOURNAL",
|
||||
"chaine",
|
||||
"OD"
|
||||
);
|
||||
$this->const[8] = array(
|
||||
"ACCOUNTING_BANK_JOURNAL",
|
||||
"chaine",
|
||||
"BQ"
|
||||
); // Deprecated Move into llx_bank_account
|
||||
$this->const[9] = array(
|
||||
$this->const[7] = array(
|
||||
"ACCOUNTING_ACCOUNT_TRANSFER_CASH",
|
||||
"chaine",
|
||||
"58"
|
||||
);
|
||||
$this->const[10] = array(
|
||||
$this->const[8] = array(
|
||||
"CHARTOFACCOUNTS",
|
||||
"chaine",
|
||||
"2"
|
||||
);
|
||||
$this->const[11] = array(
|
||||
"ACCOUNTING_MODELCSV",
|
||||
$this->const[9] = array(
|
||||
"ACCOUNTING_EXPORT_MODELCSV",
|
||||
"chaine",
|
||||
"0"
|
||||
"1"
|
||||
);
|
||||
$this->const[12] = array(
|
||||
$this->const[10] = array(
|
||||
"ACCOUNTING_LENGTH_GACCOUNT",
|
||||
"chaine",
|
||||
""
|
||||
);
|
||||
$this->const[13] = array(
|
||||
$this->const[11] = array(
|
||||
"ACCOUNTING_LENGTH_AACCOUNT",
|
||||
"chaine",
|
||||
""
|
||||
);
|
||||
$this->const[14] = array(
|
||||
$this->const[12] = array(
|
||||
"ACCOUNTING_LIMIT_LIST_VENTILATION",
|
||||
"chaine",
|
||||
"50"
|
||||
);
|
||||
$this->const[15] = array(
|
||||
$this->const[13] = array(
|
||||
"ACCOUNTING_LIST_SORT_VENTILATION_TODO",
|
||||
"yesno",
|
||||
"1"
|
||||
);
|
||||
$this->const[16] = array(
|
||||
$this->const[14] = array(
|
||||
"ACCOUNTING_LIST_SORT_VENTILATION_DONE",
|
||||
"yesno",
|
||||
"1"
|
||||
);
|
||||
$this->const[15] = array (
|
||||
"ACCOUNTING_GROUPBYACCOUNT",
|
||||
"yesno",
|
||||
"1"
|
||||
);
|
||||
$this->const[16] = array (
|
||||
"ACCOUNTING_EXPORT_DATE",
|
||||
"chaine",
|
||||
"%d%m%Y"
|
||||
);
|
||||
$this->const[17] = array (
|
||||
"ACCOUNTING_EXPORT_PIECE",
|
||||
"yesno",
|
||||
"1"
|
||||
);
|
||||
$this->const[18] = array (
|
||||
"ACCOUNTING_EXPORT_GLOBAL_ACCOUNT",
|
||||
"yesno",
|
||||
"1"
|
||||
);
|
||||
$this->const[19] = array (
|
||||
"ACCOUNTING_EXPORT_LABEL",
|
||||
"yesno",
|
||||
"1"
|
||||
);
|
||||
$this->const[20] = array (
|
||||
"ACCOUNTING_EXPORT_AMOUNT",
|
||||
"yesno",
|
||||
"1"
|
||||
);
|
||||
$this->const[21] = array (
|
||||
"ACCOUNTING_EXPORT_DEVISE",
|
||||
"yesno",
|
||||
"1"
|
||||
);
|
||||
|
||||
// Tabs
|
||||
$this->tabs = array();
|
||||
|
||||
@@ -50,7 +50,7 @@ class modAdherent extends DolibarrModules
|
||||
$this->family = "hr";
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
$this->description = "Gestion des adhérents d'une association";
|
||||
$this->description = "Management of members of a foundation or association";
|
||||
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
$this->special = 0;
|
||||
@@ -137,7 +137,7 @@ class modAdherent extends DolibarrModules
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 75;
|
||||
$this->rights[$r][1] = 'Setup types and attributes of members';
|
||||
$this->rights[$r][1] = 'Setup types of membership';
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'configurer';
|
||||
|
||||
@@ -128,7 +128,8 @@ class modCommande extends DolibarrModules
|
||||
$this->rights[$r][1] = 'Valider les commandes clients';
|
||||
$this->rights[$r][2] = 'd';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'valider';
|
||||
$this->rights[$r][4] = 'order_advance';
|
||||
$this->rights[$r][5] = 'validate';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 86;
|
||||
|
||||
@@ -50,7 +50,7 @@ class modDeplacement extends DolibarrModules
|
||||
$this->description = "Gestion des notes de frais et deplacements"; // Si traduction Module75Desc non trouvee
|
||||
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = 'dolibarr';
|
||||
$this->version = 'dolibarr_deprecated';
|
||||
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
$this->special = 0;
|
||||
@@ -95,17 +95,17 @@ class modDeplacement extends DolibarrModules
|
||||
$this->rights[3][3] = 0;
|
||||
$this->rights[3][4] = 'supprimer';
|
||||
|
||||
$this->rights[3][0] = 174;
|
||||
$this->rights[3][1] = 'Lire toutes les notes de frais';
|
||||
$this->rights[3][2] = 'd';
|
||||
$this->rights[3][3] = 0;
|
||||
$this->rights[3][4] = 'readall';
|
||||
$this->rights[4][0] = 174;
|
||||
$this->rights[4][1] = 'Lire toutes les notes de frais';
|
||||
$this->rights[4][2] = 'd';
|
||||
$this->rights[4][3] = 0;
|
||||
$this->rights[4][4] = 'readall';
|
||||
|
||||
$this->rights[6][0] = 178;
|
||||
$this->rights[6][1] = 'Exporter les notes de frais et deplacements';
|
||||
$this->rights[6][2] = 'd';
|
||||
$this->rights[6][3] = 0;
|
||||
$this->rights[6][4] = 'export';
|
||||
$this->rights[5][0] = 178;
|
||||
$this->rights[5][1] = 'Exporter les notes de frais et deplacements';
|
||||
$this->rights[5][2] = 'd';
|
||||
$this->rights[5][3] = 0;
|
||||
$this->rights[5][4] = 'export';
|
||||
|
||||
// Exports
|
||||
$r=0;
|
||||
|
||||
@@ -31,7 +31,7 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
||||
/**
|
||||
* Classe de description et activation du module Document
|
||||
*/
|
||||
class modDocument extends DolibarrModules
|
||||
class modDocumentGeneration extends DolibarrModules
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -42,12 +42,12 @@ class modDocument extends DolibarrModules
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->numero = 1510;
|
||||
$this->numero = 1520;
|
||||
|
||||
$this->family = "technic";
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
$this->description = "Generation de courriers/publipostages papiers";
|
||||
$this->description = "Direct mail document generation";
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = 'development';
|
||||
|
||||
@@ -56,7 +56,7 @@ class modDocument extends DolibarrModules
|
||||
$this->picto='email';
|
||||
|
||||
// Data directories to create when module is enabled
|
||||
$this->dirs = array("/document/temp");
|
||||
$this->dirs = array("/documentgeneration/temp");
|
||||
|
||||
// Config pages
|
||||
//$this->config_page_url = array("document.php");
|
||||
@@ -65,7 +65,7 @@ class modDocument extends DolibarrModules
|
||||
$this->depends = array();
|
||||
$this->requiredby = array();
|
||||
$this->conflictwith = array();
|
||||
$this->langfiles = array("orders","bills","companies");
|
||||
$this->langfiles = array("orders","bills","companies","mails");
|
||||
|
||||
// Constantes
|
||||
|
||||
@@ -80,14 +80,14 @@ class modDocument extends DolibarrModules
|
||||
|
||||
$r=0;
|
||||
|
||||
$this->rights[$r][0] = 1511;
|
||||
$this->rights[$r][0] = 1521;
|
||||
$this->rights[$r][1] = 'Lire les documents';
|
||||
$this->rights[$r][2] = 'r';
|
||||
$this->rights[$r][3] = 1;
|
||||
$this->rights[$r][4] = 'lire';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 1512;
|
||||
$this->rights[$r][0] = 1522;
|
||||
$this->rights[$r][1] = 'Supprimer les documents clients';
|
||||
$this->rights[$r][2] = 'd';
|
||||
$this->rights[$r][3] = 0;
|
||||
122
htdocs/core/modules/modDynamicPrices.class.php
Normal file
122
htdocs/core/modules/modDynamicPrices.class.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Ion Agorria <ion@agorria.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup produit Module dynamic prices
|
||||
* \brief Module to manage dynamic prices in products
|
||||
* \file htdocs/core/modules/modDynamicPrices.class.php
|
||||
* \ingroup produit
|
||||
* \brief File to describe module to manage dynamic prices in products
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class descriptor of DynamicPrices module
|
||||
*/
|
||||
class modDynamicPrices extends DolibarrModules
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor. Define names, constants, directories, boxes, permissions
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->numero = 2200;
|
||||
|
||||
$this->family = "products";
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
$this->description = "Enable the usage of math expressions for prices";
|
||||
$this->version = 'experimental'; // 'experimental' or 'dolibarr' or version
|
||||
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||
$this->special = 0;
|
||||
// Name of image file used for this module.
|
||||
$this->picto='technic';
|
||||
|
||||
// Data directories to create when module is enabled
|
||||
$this->dirs = array();
|
||||
|
||||
// Config pages
|
||||
//-------------
|
||||
//$this->config_page_url = array();
|
||||
|
||||
// Dependancies
|
||||
//-------------
|
||||
$this->depends = array();
|
||||
$this->requiredby = array();
|
||||
$this->langfiles = array("other");
|
||||
|
||||
// Constantes
|
||||
//-----------
|
||||
$this->const = array();
|
||||
|
||||
// New pages on tabs
|
||||
// -----------------
|
||||
$this->tabs = array();
|
||||
|
||||
// Boxes
|
||||
//------
|
||||
$this->boxes = array();
|
||||
|
||||
// Permissions
|
||||
//------------
|
||||
$this->rights = array();
|
||||
$this->rights_class = 'dynamicprices';
|
||||
$r=0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function called when module is enabled.
|
||||
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||
* It also creates data directories
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function init($options='')
|
||||
{
|
||||
// Prevent pb of modules not correctly disabled
|
||||
//$this->remove($options);
|
||||
|
||||
$sql = array();
|
||||
|
||||
return $this->_init($sql,$options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when module is disabled.
|
||||
* Remove from database constants, boxes and permissions from Dolibarr database.
|
||||
* Data directories are not deleted
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function remove($options='')
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
return $this->_remove($sql,$options);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -151,7 +151,8 @@ class modExpedition extends DolibarrModules
|
||||
$this->rights[$r][1] = 'Valider les expeditions';
|
||||
$this->rights[$r][2] = 'd';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'valider';
|
||||
$this->rights[$r][4] = 'shipping_advance';
|
||||
$this->rights[$r][5] = 'validate';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 105; // id de la permission
|
||||
@@ -197,8 +198,8 @@ class modExpedition extends DolibarrModules
|
||||
$this->rights[$r][1] = 'Valider les bons de livraison';
|
||||
$this->rights[$r][2] = 'd';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'livraison';
|
||||
$this->rights[$r][5] = 'valider';
|
||||
$this->rights[$r][4] = 'livraison_advance';
|
||||
$this->rights[$r][5] = 'validate';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 1109;
|
||||
|
||||
345
htdocs/core/modules/modExpenseReport.class.php
Executable file
345
htdocs/core/modules/modExpenseReport.class.php
Executable file
@@ -0,0 +1,345 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
||||
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup Indicateurs
|
||||
* \brief Module indicateurs
|
||||
* Such a file must be copied into htdocs/includes/module directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/indicateurs/core/modules/modExpenseReport.class.php
|
||||
* \ingroup indicateur
|
||||
* \brief Description and activation file for module ExpenseReport
|
||||
*/
|
||||
include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
|
||||
|
||||
|
||||
/**
|
||||
* Description and activation class for module ExpenseReport
|
||||
*/
|
||||
class modExpenseReport extends DolibarrModules
|
||||
{
|
||||
/**
|
||||
* Constructor. Define names, constants, directories, boxes, permissions
|
||||
*
|
||||
* @param Database $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
// Id for module (must be unique).
|
||||
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
|
||||
$this->numero = 770;
|
||||
// Key text used to identify module (for permissions, menus, etc...)
|
||||
$this->rights_class = 'deplacement';
|
||||
|
||||
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
|
||||
// It is used to group modules in module setup page
|
||||
$this->family = "hr";
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->description = "Manage and claim expense reports (transportation, meal, ...)";
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = 'dolibarr';
|
||||
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||
$this->special = 0;
|
||||
// Name of image file used for this module.
|
||||
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
|
||||
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
|
||||
$this->picto='trip';
|
||||
|
||||
// Defined if the directory /mymodule/inc/triggers/ contains triggers or not
|
||||
$this->triggers = 0;
|
||||
|
||||
// Data directories to create when module is enabled.
|
||||
// Example: this->dirs = array("/mymodule/temp");
|
||||
$this->dirs = array();
|
||||
$r=0;
|
||||
|
||||
// Relative path to module style sheet if exists. Example: '/mymodule/css/mycss.css'.
|
||||
//$this->style_sheet = '/mymodule/mymodule.css.php';
|
||||
|
||||
// Config pages. Put here list of php page names stored in admmin directory used to setup module.
|
||||
$this->config_page_url = array();
|
||||
|
||||
// Dependencies
|
||||
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
|
||||
// $this->conflictwith = array("modDeplacement");
|
||||
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
||||
$this->phpmin = array(4,3); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
|
||||
$this->langfiles = array("companies","trips","deplacement@deplacement");
|
||||
|
||||
// Constants
|
||||
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
|
||||
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
|
||||
// 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0)
|
||||
$this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
|
||||
|
||||
// Array to add new pages in new tabs
|
||||
$this->tabs = array();
|
||||
// where entity can be
|
||||
// 'thirdparty' to add a tab in third party view
|
||||
// 'intervention' to add a tab in intervention view
|
||||
// 'order_supplier' to add a tab in supplier order view
|
||||
// 'invoice_supplier' to add a tab in supplier invoice view
|
||||
// 'invoice' to add a tab in customer invoice view
|
||||
// 'order' to add a tab in customer order view
|
||||
// 'product' to add a tab in product view
|
||||
// 'stock' to add a tab in stock view
|
||||
// 'propal' to add a tab in propal view
|
||||
// 'member' to add a tab in fundation member view
|
||||
// 'contract' to add a tab in contract view
|
||||
// 'user' to add a tab in user view
|
||||
// 'group' to add a tab in group view
|
||||
// 'contact' to add a tab in contact view
|
||||
|
||||
|
||||
// Boxes
|
||||
$this->boxes = array(); // List of boxes
|
||||
$r=0;
|
||||
|
||||
// Add here list of php file(s) stored in includes/boxes that contains class to show a box.
|
||||
// Example:
|
||||
//$this->boxes[$r][1] = "myboxa.php";
|
||||
//$r++;
|
||||
//$this->boxes[$r][1] = "myboxb.php";
|
||||
//$r++;
|
||||
|
||||
|
||||
// Permissions
|
||||
$this->rights = array(); // Permission array used by this module
|
||||
$this->rights_class = 'expensereport';
|
||||
|
||||
$this->rights[1][0] = 771;
|
||||
$this->rights[1][1] = 'Read expense reports (own and his subordinates)';
|
||||
$this->rights[1][2] = 'r';
|
||||
$this->rights[1][3] = 1;
|
||||
$this->rights[1][4] = 'lire';
|
||||
|
||||
$this->rights[3][0] = 772;
|
||||
$this->rights[3][1] = 'Create/modify expense reports';
|
||||
$this->rights[3][2] = 'w';
|
||||
$this->rights[3][3] = 0;
|
||||
$this->rights[3][4] = 'creer';
|
||||
|
||||
$this->rights[4][0] = 773;
|
||||
$this->rights[4][1] = 'Delete expense reports';
|
||||
$this->rights[4][2] = 'd';
|
||||
$this->rights[4][3] = 0;
|
||||
$this->rights[4][4] = 'supprimer';
|
||||
|
||||
$this->rights[2][0] = 774;
|
||||
$this->rights[2][1] = 'Read all expense reports';
|
||||
$this->rights[2][2] = 'r';
|
||||
$this->rights[2][3] = 1;
|
||||
$this->rights[2][4] = 'readall';
|
||||
|
||||
$this->rights[6][0] = 775;
|
||||
$this->rights[6][1] = 'Approve expense reports';
|
||||
$this->rights[6][2] = 'w';
|
||||
$this->rights[6][3] = 0;
|
||||
$this->rights[6][4] = 'to_validate';
|
||||
|
||||
$this->rights[7][0] = 776;
|
||||
$this->rights[7][1] = 'Pay expense reports';
|
||||
$this->rights[7][2] = 'w';
|
||||
$this->rights[7][3] = 0;
|
||||
$this->rights[7][4] = 'to_paid';
|
||||
|
||||
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
|
||||
{
|
||||
$this->rights[8][0] = 777;
|
||||
$this->rights[8][1] = 'Synchroniser les NDF avec un compte courant';
|
||||
$this->rights[8][2] = 'w';
|
||||
$this->rights[8][3] = 0;
|
||||
$this->rights[8][4] = 'synchro';
|
||||
|
||||
$this->rights[9][0] = 778;
|
||||
$this->rights[9][1] = 'Exporter les NDF au format CSV';
|
||||
$this->rights[9][2] = 'r';
|
||||
$this->rights[9][3] = 0;
|
||||
$this->rights[9][4] = 'export_csv';
|
||||
}
|
||||
|
||||
$this->rights[5][0] = 779;
|
||||
$this->rights[5][1] = 'Export expense reports';
|
||||
$this->rights[5][2] = 'r';
|
||||
$this->rights[5][3] = 0;
|
||||
$this->rights[5][4] = 'export';
|
||||
|
||||
// Exports
|
||||
$r=0;
|
||||
|
||||
$r++;
|
||||
$this->export_code[$r]='trips_'.$r;
|
||||
$this->export_label[$r]='ListTripsAndExpenses';
|
||||
$this->export_permission[$r]=array(array("expensereport","export"));
|
||||
$this->export_fields_array[$r]=array('d.rowid'=>"TripId",'d.type'=>"Type",'d.km'=>"FeesKilometersOrAmout",'d.note'=>'NotePrivate','d.note_public'=>'NotePublic','s.nom'=>'ThirdParty','u.lastname'=>'Lastname','u.firstname'=>'Firstname','d.dated'=>"Date");
|
||||
$this->export_entities_array[$r]=array('d.rowid'=>"Trip",'d.type'=>"Trip",'d.km'=>"Trip",'d.note'=>'Trip','d.note_public'=>'Trip','s.nom'=>'company','u.lastname'=>'user','u.firstname'=>'user','d.dated'=>"Date");
|
||||
$this->export_alias_array[$r]=array('d.rowid'=>"idtrip",'d.type'=>"type",'d.km'=>"km",'d.note'=>'note','d.note_public'=>'note_public','s.nom'=>'companyname','u.lastname'=>'name','u.firstname'=>'firstname','d.dated'=>'date');
|
||||
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
|
||||
$this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'expensereport as d';
|
||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid';
|
||||
$this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid';
|
||||
$this->export_sql_end[$r] .=' AND d.entity = '.$conf->entity;
|
||||
|
||||
|
||||
|
||||
// Main menu entries
|
||||
$this->menu = array(); // List of menus to add
|
||||
$r=0;
|
||||
|
||||
// Example to declare a Left Menu entry: fk_mainmenu=home,fk_leftmenu=modulesadmintools
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=accountancy', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'TripsAndExpenses',
|
||||
'mainmenu'=>'accountancy',
|
||||
'leftmenu'=>'expensereport',
|
||||
'url'=>'/expensereport/index.php',
|
||||
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100,
|
||||
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=accountancy,fk_leftmenu=expensereport', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'New',
|
||||
'mainmenu'=>'accountancy',
|
||||
'leftmenu'=>'expensereport_detail',
|
||||
'url'=>'/expensereport/card.php?action=create',
|
||||
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100,
|
||||
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=accountancy,fk_leftmenu=expensereport', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'List',
|
||||
'mainmenu'=>'accountancy',
|
||||
'leftmenu'=>'expensereport_detail',
|
||||
'url'=>'/expensereport/list.php',
|
||||
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100,
|
||||
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=accountancy,fk_leftmenu=expensereport', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'Statistics',
|
||||
'mainmenu'=>'accountancy',
|
||||
'leftmenu'=>'expensereport_detail',
|
||||
'url'=>'/expensereport/stats/index.php',
|
||||
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100,
|
||||
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=accountancy,fk_leftmenu=expensereport', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'ExportTripCSV',
|
||||
'mainmenu'=>'accountancy',
|
||||
'leftmenu'=>'expensereport_detail',
|
||||
'url'=>'/expensereport/export_csv.php',
|
||||
'langs'=>'expensereport', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100,
|
||||
'enabled'=>'$conf->global->DEPLACEMENT_TO_CLEAN', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=accountancy,fk_leftmenu=expensereport', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'Synchro_Compta',
|
||||
'mainmenu'=>'accountancy',
|
||||
'leftmenu'=>'expensereport_detail',
|
||||
'url'=>'/expensereport/synchro_compta.php',
|
||||
'langs'=>'expensereport', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100,
|
||||
'enabled'=>'$conf->global->DEPLACEMENT_TO_CLEAN', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when module is enabled.
|
||||
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||
* It also creates data directories.
|
||||
*
|
||||
* @param string $options Options
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function init($options='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->remove($options);
|
||||
|
||||
$result=$this->_load_tables('/deplacement/sql/');
|
||||
|
||||
$sql = array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'teclib' AND entity = ".$conf->entity,
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('teclib','deplacement',".$conf->entity.")"
|
||||
);
|
||||
|
||||
return $this->_init($sql,$options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when module is disabled.
|
||||
* Remove from database constants, boxes and permissions from Dolibarr database.
|
||||
* Data directories are not deleted.
|
||||
*
|
||||
* @param string $options Options
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function remove($options='')
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
return $this->_remove($sql,$options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -137,7 +137,8 @@ class modFacture extends DolibarrModules
|
||||
$this->rights[$r][1] = 'Valider les factures';
|
||||
$this->rights[$r][2] = 'a';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'valider';
|
||||
$this->rights[$r][4] = 'invoice_advance';
|
||||
$this->rights[$r][5] = 'validate';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 15;
|
||||
|
||||
@@ -150,8 +150,8 @@ class modFournisseur extends DolibarrModules
|
||||
$this->rights[$r][1] = 'Valider une commande fournisseur';
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'commande';
|
||||
$this->rights[$r][5] = 'valider';
|
||||
$this->rights[$r][4] = 'supplier_order_advance';
|
||||
$this->rights[$r][5] = 'validate';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 1185;
|
||||
@@ -206,8 +206,8 @@ class modFournisseur extends DolibarrModules
|
||||
$this->rights[$r][1] = 'Valider une facture fournisseur';
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'facture';
|
||||
$this->rights[$r][5] = 'valider';
|
||||
$this->rights[$r][4] = 'supplier_invoice_advance';
|
||||
$this->rights[$r][5] = 'validate';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 1234;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* 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
|
||||
@@ -106,8 +107,8 @@ class modMargin extends DolibarrModules
|
||||
'url'=>'/margin/index.php',
|
||||
'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100,
|
||||
'enabled'=>'$user->rights->margins->liretous', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
|
||||
'enabled'=>'$conf->margin->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'$user->rights->margins->liretous', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
@@ -129,6 +130,14 @@ class modMargin extends DolibarrModules
|
||||
$this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
|
||||
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
|
||||
$this->rights[$r][4] = 'creer';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 59003; // id de la permission
|
||||
$this->rights[$r][1] = 'Read every user margin'; // libelle de la permission
|
||||
$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
|
||||
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
|
||||
$this->rights[$r][4] = 'read';
|
||||
$this->rights[$r][5] = 'all';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Frederic France <frederic.france@free.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
|
||||
@@ -15,43 +16,43 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \defgroup printipp Module printipp
|
||||
* \brief Module pour imprimer via CUPS
|
||||
/** \defgroup printing Module printing
|
||||
* \brief Module for activation of printing icon
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/modPrintIPP.class.php
|
||||
* \ingroup printipp
|
||||
* \brief Fichier de description et activation du module OSCommerce2
|
||||
* \file htdocs/core/modules/modPrinting.class.php
|
||||
* \ingroup printing
|
||||
* \brief Fichier de description et activation du module Printing
|
||||
*/
|
||||
include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
|
||||
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \class modPrintIPP
|
||||
* \brief Classe de description et activation du module PrintIPP
|
||||
* \class modPrinting
|
||||
* \brief Classe de description et activation du module Printing
|
||||
*/
|
||||
class modPrintIPP extends DolibarrModules
|
||||
class modPrinting extends DolibarrModules
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db ;
|
||||
$this->numero = 54000;
|
||||
$this->numero = 112000;
|
||||
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
|
||||
// It is used to group modules in module setup page
|
||||
$this->family = "other";
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
$this->description = "Print via Cups IPP Printer.";
|
||||
$this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version
|
||||
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->description = "Enable Direct Printing System.";
|
||||
$this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||
$this->special = 1;
|
||||
@@ -64,15 +65,15 @@ class modPrintIPP extends DolibarrModules
|
||||
$this->dirs = array();
|
||||
|
||||
// Config pages
|
||||
$this->config_page_url = array("printipp.php@printipp");
|
||||
$this->config_page_url = array("printing.php@printing");
|
||||
|
||||
// Dependances
|
||||
$this->depends = array();
|
||||
$this->requiredby = array();
|
||||
$this->phpmin = array(5,1); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module
|
||||
$this->phpmin = array(5,1); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module
|
||||
$this->conflictwith = array();
|
||||
$this->langfiles = array("printipp");
|
||||
$this->langfiles = array("printing");
|
||||
|
||||
// Constantes
|
||||
$this->const = array();
|
||||
@@ -82,7 +83,7 @@ class modPrintIPP extends DolibarrModules
|
||||
|
||||
// Permissions
|
||||
$this->rights = array();
|
||||
$this->rights_class = 'printipp';
|
||||
$this->rights_class = 'printing';
|
||||
|
||||
$r=0;
|
||||
// $this->rights[$r][0] Id permission (unique tous modules confondus)
|
||||
@@ -93,8 +94,8 @@ class modPrintIPP extends DolibarrModules
|
||||
// $this->rights[$r][5] Niveau 2 pour nommer permission dans code
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 54001;
|
||||
$this->rights[$r][1] = 'Printer';
|
||||
$this->rights[$r][0] = 112001;
|
||||
$this->rights[$r][1] = 'Printing';
|
||||
$this->rights[$r][2] = 'r';
|
||||
$this->rights[$r][3] = 1;
|
||||
$this->rights[$r][4] = 'read';
|
||||
@@ -105,16 +106,16 @@ class modPrintIPP extends DolibarrModules
|
||||
|
||||
// This is to declare the Top Menu entry:
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Put 0 if this is a top menu
|
||||
'type'=>'left', // This is a Top menu entry
|
||||
'titre'=>'Printer',
|
||||
'mainmenu'=>'printer',
|
||||
'url'=>'/printipp/index.php',
|
||||
'langs'=>'printipp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'type'=>'left', // This is a Top menu entry
|
||||
'titre'=>'Printing',
|
||||
'mainmenu'=>'printing',
|
||||
'url'=>'/printing/index.php',
|
||||
'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>300,
|
||||
'enabled'=>'$conf->printipp->enabled && $leftmenu==\'modulesadmintools\'',
|
||||
'perms'=>'$user->rights->printipp->read', // Use 'perms'=>'1' if you want your menu with no permission rules
|
||||
'enabled'=>'$conf->printing->enabled && $leftmenu==\'modulesadmintools\'',
|
||||
'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules
|
||||
'target'=>'',
|
||||
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
|
||||
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
|
||||
|
||||
$r++;
|
||||
|
||||
@@ -122,13 +123,13 @@ class modPrintIPP extends DolibarrModules
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when module is enabled.
|
||||
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||
* It also creates data directories
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
* Function called when module is enabled.
|
||||
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||
* It also creates data directories
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function init($options='')
|
||||
{
|
||||
$sql = array();
|
||||
@@ -136,15 +137,15 @@ class modPrintIPP extends DolibarrModules
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when module is disabled.
|
||||
* Remove from database constants, boxes and permissions from Dolibarr database.
|
||||
* Data directories are not deleted
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function remove($options='')
|
||||
/**
|
||||
* Function called when module is disabled.
|
||||
* Remove from database constants, boxes and permissions from Dolibarr database.
|
||||
* Data directories are not deleted
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function remove($options='')
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
@@ -49,7 +49,7 @@ class modProductBatch extends DolibarrModules
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
$this->description = "Batch number, eat-by and sell-by date management module";
|
||||
|
||||
$this->rights_class = 'stock';
|
||||
$this->rights_class = 'productbatch';
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = 'experimental';
|
||||
// Key used in llx_const table to save module status enabled/disabled (where dluo is value of property name of module in uppercase)
|
||||
@@ -67,7 +67,7 @@ class modProductBatch extends DolibarrModules
|
||||
$this->config_page_url = array();
|
||||
|
||||
// Dependencies
|
||||
$this->depends = array("modProduct","modStock"); // List of modules id that must be enabled if this module is enabled
|
||||
$this->depends = array("modProduct","modStock","modExpedition","modSupplier"); // List of modules id that must be enabled if this module is enabled. modExpedition is required to manage batch exit (by manual stock decrease on shipment), modSupplier to manage batch entry (after supplier order).
|
||||
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
||||
$this->phpmin = array(5,0); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
|
||||
@@ -112,8 +112,16 @@ class modProductBatch extends DolibarrModules
|
||||
*/
|
||||
function init($options='')
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
$sql = array();
|
||||
|
||||
|
||||
if(! empty($conf->cashdesk->enabled)) {
|
||||
if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
|
||||
$res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ class modProjet extends DolibarrModules
|
||||
's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
|
||||
'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.description'=>"Text",
|
||||
'pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Number",'pt.progress'=>"Number",'pt.description'=>"Text",
|
||||
'ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:Name",'ptt.note'=>"Text");
|
||||
'ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
|
||||
|
||||
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
|
||||
's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',
|
||||
|
||||
@@ -130,7 +130,8 @@ class modPropale extends DolibarrModules
|
||||
$this->rights[$r][1] = 'Valider les propositions commerciales'; // libelle de la permission
|
||||
$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
|
||||
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
|
||||
$this->rights[$r][4] = 'valider';
|
||||
$this->rights[$r][4] = 'propal_advance';
|
||||
$this->rights[$r][5] = 'validate';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 25; // id de la permission
|
||||
|
||||
0
htdocs/core/modules/modSyncSupplierWebServices.class.php
Executable file → Normal file
0
htdocs/core/modules/modSyncSupplierWebServices.class.php
Executable file → Normal file
@@ -50,7 +50,7 @@ class modSyslog extends DolibarrModules
|
||||
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->description = "Activate debug logs (syslog)";
|
||||
// Can be enabled / disabled only in the main company
|
||||
$this->core_enabled = 1;
|
||||
$this->core_enabled = true;
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
|
||||
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
|
||||
|
||||
@@ -49,7 +49,7 @@ class modUser extends DolibarrModules
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
$this->description = "Gestion des utilisateurs (requis)";
|
||||
$this->always_enabled = 1; // Can't be disabled
|
||||
$this->always_enabled = true; // Can't be disabled
|
||||
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = 'dolibarr';
|
||||
|
||||
0
htdocs/core/modules/printing/index.html
Normal file
0
htdocs/core/modules/printing/index.html
Normal file
86
htdocs/core/modules/printing/modules_printing.php
Normal file
86
htdocs/core/modules/printing/modules_printing.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2014 Frederic France <frederic.france@free.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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/mailings/modules_printing.php
|
||||
* \ingroup printing
|
||||
* \brief File with parent class of printing modules
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
* Parent class of emailing target selectors modules
|
||||
*/
|
||||
class PrintingDriver
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of printing driver
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $maxfilenamelength Max length of value to show
|
||||
* @return array List of drivers
|
||||
*/
|
||||
static function listDrivers($db,$maxfilenamelength=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$type='printing';
|
||||
$liste=array();
|
||||
|
||||
$moduledir=DOL_DOCUMENT_ROOT."/core/modules/printing/";
|
||||
$tmpfiles=dol_dir_list($moduledir,'all',0,'\modules.php','','name',SORT_ASC,0);
|
||||
foreach($tmpfiles as $record) {
|
||||
$list[$record['fullname']]=str_replace('.modules.php', '',$record['name']);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return description of Printing Module
|
||||
*
|
||||
* @return string Return translation of key PrintingModuleDescXXX where XXX is module name, or $this->desc if not exists
|
||||
*/
|
||||
function getDesc()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("printing");
|
||||
$transstring="PrintingModuleDesc".$this->name;
|
||||
if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring);
|
||||
else return $this->desc;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
355
htdocs/core/modules/printing/printgcp.modules.php
Normal file
355
htdocs/core/modules/printing/printgcp.modules.php
Normal file
@@ -0,0 +1,355 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2014 Frederic France <frederic.france@free.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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/printing/printgcp.modules.php
|
||||
* \ingroup printing
|
||||
* \brief File to provide printing with Google Cloud Print
|
||||
*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
||||
|
||||
/**
|
||||
* Class to provide printing with Google Cloud Print
|
||||
*/
|
||||
class printing_printgcp extends PrintingDriver
|
||||
{
|
||||
var $name = 'printgcp';
|
||||
var $desc = 'PrintGCPDesc';
|
||||
var $picto = 'printer';
|
||||
var $active = 'PRINTING_PRINTGCP';
|
||||
var $conf = array();
|
||||
var $login = '';
|
||||
var $password = '';
|
||||
var $authtoken = '';
|
||||
var $db;
|
||||
|
||||
const LOGIN_URL = 'https://www.google.com/accounts/ClientLogin';
|
||||
const PRINTERS_SEARCH_URL = 'https://www.google.com/cloudprint/interface/search';
|
||||
const PRINT_URL = 'https://www.google.com/cloudprint/interface/submit';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->db = $db;
|
||||
$this->login = $conf->global->PRINTGCP_LOGIN;
|
||||
$this->password = $conf->global->PRINTGCP_PASSWORD;
|
||||
$this->authtoken = $conf->global->PRINTGCP_AUTHTOKEN;
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_LOGIN', 'required'=>1, 'example'=>'user@gmail.com', 'type'=>'text');
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_PASSWORD', 'required'=>1, 'example'=>'', 'type'=>'password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of available printers
|
||||
*
|
||||
* @return string html list of printers
|
||||
*/
|
||||
function listAvailablePrinters()
|
||||
{
|
||||
global $bc, $conf, $langs;
|
||||
$langs->load('printing');
|
||||
$var=true;
|
||||
|
||||
$html = '<tr class="liste_titre">';
|
||||
$html.= '<td>'.$langs->trans('GCP_Name').'</td>';
|
||||
$html.= '<td>'.$langs->trans('GCP_displayName').'</td>';
|
||||
$html.= '<td>'.$langs->trans('GCP_Id').'</td>';
|
||||
$html.= '<td>'.$langs->trans('GCP_OwnerName').'</td>';
|
||||
$html.= '<td>'.$langs->trans('GCP_State').'</td>';
|
||||
$html.= '<td>'.$langs->trans('GCP_connectionStatus').'</td>';
|
||||
$html.= '<td>'.$langs->trans('GCP_Type').'</td>';
|
||||
$html.= '<td align="center">'.$langs->trans("Select").'</td>';
|
||||
$html.= '</tr>'."\n";
|
||||
$list = $this->getlist_available_printers();
|
||||
//$html.= '<td><pre>'.print_r($list,true).'</pre></td>';
|
||||
$var = true;
|
||||
foreach ($list['available'] as $printer_det)
|
||||
{
|
||||
$var=!$var;
|
||||
$html.= "<tr ".$bc[$var].">";
|
||||
$html.= '<td>'.$printer_det['name'].'</td>';
|
||||
$html.= '<td>'.$printer_det['displayName'].'</td>';
|
||||
$html.= '<td>'.$printer_det['id'].'</td>'; // id to identify printer to use
|
||||
$html.= '<td>'.$printer_det['ownerName'].'</td>';
|
||||
$html.= '<td>'.$printer_det['status'].'</td>';
|
||||
$html.= '<td>'.$langs->trans('STATE_'.$printer_det['connectionStatus']).'</td>';
|
||||
$html.= '<td>'.$langs->trans('TYPE_'.$printer_det['type']).'</td>';
|
||||
// Defaut
|
||||
$html.= '<td align="center">';
|
||||
if ($conf->global->PRINTING_GCP_DEFAULT == $printer_det['id'])
|
||||
{
|
||||
$html.= img_picto($langs->trans("Default"),'on');
|
||||
}
|
||||
else
|
||||
$html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTING_GCP_DEFAULT&driver=printgcp&value='.urlencode($printer_det['id']).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||
$html.= '</td>';
|
||||
$html.= '</tr>'."\n";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of available printers
|
||||
*
|
||||
* @return array list of printers
|
||||
*/
|
||||
function getlist_available_printers()
|
||||
{
|
||||
global $conf,$db;
|
||||
if ($this->authtoken=='') {
|
||||
$this->GoogleLogin();
|
||||
}
|
||||
$ret['available'] = $this->get_printer_detail();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of printers
|
||||
*
|
||||
* @return array list of printers
|
||||
*/
|
||||
function get_printer_detail()
|
||||
{
|
||||
// Check if we have auth token
|
||||
if(empty($this->authtoken)) {
|
||||
// We don't have auth token so throw exception
|
||||
throw new Exception("Please first login to Google by calling loginToGoogle function");
|
||||
}
|
||||
// Prepare auth headers with auth token
|
||||
$authheaders = array("Authorization: GoogleLogin auth=".$this->authtoken,
|
||||
"GData-Version: 3.0",
|
||||
);
|
||||
// Make Http call to get printers added by user to Google Cloud Print
|
||||
$responsedata = $this->makeCurl(self::PRINTERS_SEARCH_URL,array(),$authheaders);
|
||||
$printers = json_decode($responsedata);
|
||||
// Check if we have printers?
|
||||
if(is_null($printers)) {
|
||||
// We dont have printers so return blank array
|
||||
return array();
|
||||
} else {
|
||||
// We have printers so returns printers as array
|
||||
return $this->parsePrinters($printers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print selected file
|
||||
*
|
||||
* @param string $file file
|
||||
* @param string $module module
|
||||
* @param string $subdir subdir for file
|
||||
* @return string '' if OK, Error message if KO
|
||||
*/
|
||||
function print_file($file, $module, $subdir='')
|
||||
{
|
||||
global $conf, $user, $db;
|
||||
if ($this->authtoken=='') {
|
||||
$this->GoogleLogin();
|
||||
}
|
||||
// si $module=commande_fournisseur alors $conf->fournisseur->commande->dir_output
|
||||
$fileprint=$conf->{$module}->dir_output;
|
||||
if ($subdir!='') $fileprint.='/'.$subdir;
|
||||
$fileprint.='/'.$file;
|
||||
// select printer uri for module order, propal,...
|
||||
$sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$module."' AND driver='printgcp' AND userid=".$user->id;
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($obj)
|
||||
{
|
||||
$printer_id=$obj->printer_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->PRINTING_GCP_DEFAULT))
|
||||
{
|
||||
$printer_id=$conf->global->PRINTING_GCP_DEFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'NoDefaultPrinterDefined';
|
||||
}
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
|
||||
$this->sendPrintToPrinter($printer_id, $file, $fileprint, 'application/pdf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends document to the printer
|
||||
*
|
||||
* @param string $printerid Printer id returned by Google Cloud Print
|
||||
* @param string $printjobtitle Job Title
|
||||
* @param string $filepath File Path to be send to Google Cloud Print
|
||||
* @param string $contenttype File content type by example application/pdf, image/png
|
||||
* @return array status array
|
||||
*/
|
||||
public function sendPrintToPrinter($printerid,$printjobtitle,$filepath,$contenttype)
|
||||
{
|
||||
$errors=0;
|
||||
// Check auth token
|
||||
if(empty($this->authtoken)) {
|
||||
$errors++;
|
||||
setEventMessage('Please first login to Google', 'warning');
|
||||
}
|
||||
// Check if printer id
|
||||
if(empty($printerid)) {
|
||||
$errors++;
|
||||
setEventMessage('No provided printer ID', 'warning');
|
||||
}
|
||||
// Open the file which needs to be print
|
||||
$handle = fopen($filepath, "rb");
|
||||
if(!$handle) {
|
||||
$errors++;
|
||||
setEventMessage('Could not read the file.');
|
||||
}
|
||||
// Read file content
|
||||
$contents = fread($handle, filesize($filepath));
|
||||
fclose($handle);
|
||||
// Prepare post fields for sending print
|
||||
$post_fields = array('printerid' => $printerid,
|
||||
'title' => $printjobtitle,
|
||||
'contentTransferEncoding' => 'base64',
|
||||
'content' => base64_encode($contents), // encode file content as base64
|
||||
'contentType' => $contenttype
|
||||
);
|
||||
// Prepare authorization headers
|
||||
$authheaders = array("Authorization: GoogleLogin auth=" . $this->authtoken);
|
||||
// Make http call for sending print Job
|
||||
$response = json_decode($this->makeCurl(self::PRINT_URL,$post_fields,$authheaders));
|
||||
// Has document been successfully sent?
|
||||
if($response->success=="1") {
|
||||
return array('status' =>true,'errorcode' =>'','errormessage'=>"");
|
||||
} else {
|
||||
return array('status' =>false,'errorcode' =>$response->errorCode,'errormessage'=>$response->message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Login into Google Account
|
||||
*
|
||||
* @return string true or false
|
||||
*/
|
||||
function GoogleLogin()
|
||||
{
|
||||
global $db, $conf;
|
||||
// Prepare post fields required for the login
|
||||
$loginpostfields = array("accountType" => "HOSTED_OR_GOOGLE",
|
||||
"Email" => $this->login,
|
||||
"Passwd" => $this->password,
|
||||
"service" => "cloudprint",
|
||||
"source" => "GCP"
|
||||
);
|
||||
// Get the Auth token
|
||||
$loginresponse = $this->makeCurl(self::LOGIN_URL,$loginpostfields);
|
||||
$token = $this->getAuthToken($loginresponse);
|
||||
if(! empty($token)&&!is_null($token)) {
|
||||
$this->authtoken = $token;
|
||||
$result=dolibarr_set_const($db, 'PRINTGCP_AUTHTOKEN', $token, 'chaine', 0, '', $conf->entity);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse json response and return printers array
|
||||
*
|
||||
* @param string $jsonobj Json response object
|
||||
* @return array return array of printers
|
||||
*/
|
||||
private function parsePrinters($jsonobj)
|
||||
{
|
||||
$printers = array();
|
||||
if (isset($jsonobj->printers)) {
|
||||
foreach ($jsonobj->printers as $gcpprinter) {
|
||||
$printers[] = array('id' =>$gcpprinter->id,
|
||||
'name' =>$gcpprinter->name,
|
||||
'defaultDisplayName' =>$gcpprinter->defaultDisplayName,
|
||||
'displayName' =>$gcpprinter->displayName,
|
||||
'ownerId' =>$gcpprinter->ownerId,
|
||||
'ownerName' =>$gcpprinter->ownerName,
|
||||
'connectionStatus' =>$gcpprinter->connectionStatus,
|
||||
'status' =>$gcpprinter->status,
|
||||
'type' =>$gcpprinter->type
|
||||
);
|
||||
}
|
||||
}
|
||||
return $printers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse data to get auth token
|
||||
*
|
||||
* @param string $response response from curl
|
||||
* @return string token
|
||||
*/
|
||||
private function getAuthToken($response)
|
||||
{
|
||||
// Search Auth tag
|
||||
preg_match("/Auth=([a-z0-9_-]+)/i", $response, $matches);
|
||||
$authtoken = @$matches[1];
|
||||
return $authtoken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Curl request
|
||||
*
|
||||
* @param string $url url to hit
|
||||
* @param array $postfields array of post fields
|
||||
* @param array $headers array of http headers
|
||||
* @return array response from curl
|
||||
*/
|
||||
private function makeCurl($url,$postfields=array(),$headers=array())
|
||||
{
|
||||
// Curl Init
|
||||
$curl = curl_init($url);
|
||||
// Curl post request
|
||||
if(! empty($postfields)) {
|
||||
// As is HTTP post curl request so set post fields
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
|
||||
}
|
||||
// Curl request headers
|
||||
if(! empty($headers)) {
|
||||
// As curl requires header so set headers here
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
// Execute the curl and return response
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
288
htdocs/core/modules/printing/printipp.modules.php
Normal file
288
htdocs/core/modules/printing/printipp.modules.php
Normal file
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2014 Frederic France <frederic.france@free.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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/printing/printipp.modules.php
|
||||
* \ingroup mailing
|
||||
* \brief File to provide printing with PrintIPP
|
||||
*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
||||
|
||||
/**
|
||||
* Class to provide printing with PrintIPP
|
||||
*/
|
||||
class printing_printipp extends PrintingDriver
|
||||
{
|
||||
var $name='printipp';
|
||||
var $desc='PrintIPPDesc';
|
||||
var $picto='printer';
|
||||
var $active='PRINTING_PRINTIPP';
|
||||
var $conf=array();
|
||||
var $host;
|
||||
var $port;
|
||||
var $userid; /* user login */
|
||||
var $user;
|
||||
var $password;
|
||||
var $error;
|
||||
var $db;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->db=$db;
|
||||
$this->host=$conf->global->PRINTIPP_HOST;
|
||||
$this->port=$conf->global->PRINTIPP_PORT;
|
||||
$this->user=$conf->global->PRINTIPP_USER;
|
||||
$this->password=$conf->global->PRINTIPP_PASSWORD;
|
||||
$this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text');
|
||||
$this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text');
|
||||
$this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"');
|
||||
$this->conf[] = array('varname'=>'PRINTIPP_PASSWORD', 'required'=>0, 'example'=>'', 'type'=>'password', 'moreattributes'=>'autocomplete="off"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Print selected file
|
||||
*
|
||||
* @param string $file file
|
||||
* @param string $module module
|
||||
* @param string $subdir subdirectory of document like for expedition subdir is sendings
|
||||
*
|
||||
* @return string '' if OK, Error message if KO
|
||||
*/
|
||||
function print_file($file, $module, $subdir='')
|
||||
{
|
||||
global $conf, $user, $db;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||
|
||||
$ipp = new CupsPrintIPP();
|
||||
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
|
||||
$ipp->setHost($this->host);
|
||||
$ipp->setPort($this->port);
|
||||
$ipp->setJobName($file,true);
|
||||
$ipp->setUserName($this->userid);
|
||||
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
|
||||
|
||||
// select printer uri for module order, propal,...
|
||||
$sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id;
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($obj)
|
||||
{
|
||||
dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id);
|
||||
$ipp->setPrinterURI($obj->printer_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->PRINTIPP_URI_DEFAULT))
|
||||
{
|
||||
dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".$conf->global->PRINTIPP_URI_DEFAULT);
|
||||
$ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'NoDefaultPrinterDefined';
|
||||
}
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
|
||||
// Set number of copy
|
||||
$ipp->setCopies($obj->copy);
|
||||
$fileprint=$conf->{$module}->dir_output;
|
||||
if ($subdir!='') $fileprint.='/'.$subdir;
|
||||
$fileprint.='/'.$file;
|
||||
$ipp->setData($fileprint);
|
||||
$ipp->printJob();
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of available printers
|
||||
*
|
||||
* @return string html list of printers
|
||||
*/
|
||||
function listAvailablePrinters()
|
||||
{
|
||||
global $bc, $conf, $langs;
|
||||
$var=true;
|
||||
|
||||
$html = '<tr class="liste_titre">';
|
||||
$html.= '<td>'.$langs->trans('IPP_Uri').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_Name').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_State').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_State_reason').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_State_reason1').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_BW').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_Color').'</td>';
|
||||
//$html.= '<td>'.$langs->trans('IPP_Device').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_Media').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_Supported').'</td>';
|
||||
$html.= '<td align="center">'.$langs->trans("Select").'</td>';
|
||||
$html.= "</tr>\n";
|
||||
$list = $this->getlist_available_printers();
|
||||
$var = true;
|
||||
foreach ($list as $value)
|
||||
{
|
||||
$var=!$var;
|
||||
$printer_det = $this->get_printer_detail($value);
|
||||
$html.= "<tr ".$bc[$var].">";
|
||||
$html.= '<td>'.$value.'</td>';
|
||||
//$html.= '<td><pre>'.print_r($printer_det,true).'</pre></td>';
|
||||
$html.= '<td>'.$printer_det->printer_name->_value0.'</td>';
|
||||
$html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).'</td>';
|
||||
$html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).'</td>';
|
||||
$html.= '<td>'.(! empty($printer_det->printer_state_reasons->_value1)?$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1):'').'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).'</td>';
|
||||
$html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).'</td>';
|
||||
//$html.= '<td>'.$printer_det->device_uri->_value0.'</td>';
|
||||
$html.= '<td>'.$printer_det->media_default->_value0.'</td>';
|
||||
$html.= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>';
|
||||
// Defaut
|
||||
$html.= '<td align="center">';
|
||||
if ($conf->global->PRINTIPP_URI_DEFAULT == $value)
|
||||
{
|
||||
$html.= img_picto($langs->trans("Default"),'on');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||
}
|
||||
$html.= '</td>';
|
||||
$html.= '</tr>'."\n";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of available printers
|
||||
*
|
||||
* @return array list of printers
|
||||
*/
|
||||
function getlist_available_printers()
|
||||
{
|
||||
global $conf,$db;
|
||||
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||
$ipp = new CupsPrintIPP();
|
||||
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
|
||||
$ipp->setHost($this->host);
|
||||
$ipp->setPort($this->port);
|
||||
$ipp->setUserName($this->userid);
|
||||
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
|
||||
$ipp->getPrinters();
|
||||
return $ipp->available_printers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get printer detail
|
||||
*
|
||||
* @param string $uri URI
|
||||
* @return array List of attributes
|
||||
*/
|
||||
function get_printer_detail($uri)
|
||||
{
|
||||
global $conf,$db;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||
$ipp = new CupsPrintIPP();
|
||||
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
|
||||
$ipp->setHost($this->host);
|
||||
$ipp->setPort($this->port);
|
||||
$ipp->setUserName($this->userid);
|
||||
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
|
||||
$ipp->setPrinterURI($uri);
|
||||
$ipp->getPrinterAttributes();
|
||||
return $ipp->printer_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* List jobs print
|
||||
*
|
||||
* @param string $module module
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function list_jobs($module)
|
||||
{
|
||||
global $conf, $db, $bc;
|
||||
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||
$ipp = new CupsPrintIPP();
|
||||
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
|
||||
$ipp->setHost($this->host);
|
||||
$ipp->setPort($this->port);
|
||||
$ipp->setUserName($this->userid);
|
||||
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
|
||||
// select printer uri for module order, propal,...
|
||||
$sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"';
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($obj)
|
||||
{
|
||||
$ipp->setPrinterURI($obj->printer_uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
// All printers
|
||||
$ipp->setPrinterURI("ipp://localhost:631/printers/");
|
||||
}
|
||||
}
|
||||
// Getting Jobs
|
||||
$ipp->getJobs(false,0,'completed',false);
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print "<td>Id</td>";
|
||||
print "<td>Owner</td>";
|
||||
print "<td>Printer</td>";
|
||||
print "<td>File</td>";
|
||||
print "<td>Status</td>";
|
||||
print "<td>Cancel</td>";
|
||||
print "</tr>\n";
|
||||
$jobs = $ipp->jobs_attributes;
|
||||
$var = True;
|
||||
//print '<pre>'.print_r($jobs,true).'</pre>';
|
||||
foreach ($jobs as $value )
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td>'.$value->job_id->_value0.'</td>';
|
||||
print '<td>'.$value->job_originating_user_name->_value0.'</td>';
|
||||
print '<td>'.$value->printer_uri->_value0.'</td>';
|
||||
print '<td>'.$value->job_name->_value0.'</td>';
|
||||
print '<td>'.$value->job_state->_value0.'</td>';
|
||||
print '<td>'.$value->job_uri->_value0.'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -135,7 +135,7 @@ class pdf_standardlabel
|
||||
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
|
||||
|
||||
// We are in a new page, then we must add a page
|
||||
if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) {
|
||||
if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
|
||||
$pdf->AddPage();
|
||||
}
|
||||
$this->_First=0;
|
||||
|
||||
@@ -138,7 +138,7 @@ class doc_generic_project_odt extends ModelePDFProjects
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
|
||||
$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key=$array_key,$outputlangs);
|
||||
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
|
||||
}
|
||||
|
||||
return $resarray;
|
||||
|
||||
@@ -92,7 +92,7 @@ class pdf_baleine extends ModelePDFProjects
|
||||
*/
|
||||
function write_file($object,$outputlangs)
|
||||
{
|
||||
global $user,$langs,$conf;
|
||||
global $conf, $hookmanager, $langs, $user;
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
|
||||
|
||||
@@ -139,7 +139,7 @@ class doc_generic_task_odt extends ModelePDFTask
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
|
||||
$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key=$array_key,$outputlangs);
|
||||
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
|
||||
}
|
||||
|
||||
return $resarray;
|
||||
|
||||
@@ -1284,7 +1284,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
|
||||
}
|
||||
|
||||
$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
|
||||
@@ -91,7 +91,7 @@ class pdf_paiement
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
global $user,$langs,$conf;
|
||||
global $conf, $hookmanager, $langs, $user;
|
||||
|
||||
$socid=0;
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
@@ -126,7 +126,7 @@ class pdf_paiement
|
||||
$hookmanager=new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
$parameters=array('file'=>$file,'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
|
||||
@@ -125,7 +125,8 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
|
||||
return 0;
|
||||
}
|
||||
|
||||
$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->datef);
|
||||
//Supplier invoices take invoice date instead of creation date for the mask
|
||||
$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->date);
|
||||
|
||||
return $numFinal;
|
||||
}
|
||||
|
||||
@@ -939,16 +939,28 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
||||
|
||||
if ($object->ref_supplier)
|
||||
{
|
||||
$posy+=5;
|
||||
$posy+=4;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R');
|
||||
}
|
||||
|
||||
$posy+=1;
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
|
||||
$posy+=5;
|
||||
$posy+=6;
|
||||
if (! empty($conf->global->PDF_SHOW_PROJECT))
|
||||
{
|
||||
$object->fetch_projet();
|
||||
$pdf->SetXY($posx,$posy);
|
||||
if (! empty($object->project->ref))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
|
||||
$posy+=4;
|
||||
}
|
||||
}
|
||||
|
||||
$pdf->SetXY($posx,$posy);
|
||||
if ($object->date)
|
||||
{
|
||||
@@ -970,7 +982,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
||||
if ($showaddress)
|
||||
{
|
||||
// Sender properties
|
||||
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
|
||||
@@ -28,9 +28,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefo
|
||||
|
||||
|
||||
/**
|
||||
\class mod_commande_fournisseur_orchidee
|
||||
\brief Classe du modele de numerotation de reference de commande fournisseur Orchidee
|
||||
*/
|
||||
* Classe du modele de numerotation de reference de commande fournisseur Orchidee
|
||||
*/
|
||||
class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
|
||||
{
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
@@ -200,7 +200,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$nblignes = count($object->lines);
|
||||
|
||||
@@ -976,15 +976,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$pdf->SetFont('', 'B', $default_font_size + 3);
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$title=$outputlangs->transnoentities("SupplierOrder");
|
||||
$title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
|
||||
$pdf->MultiCell(100, 3, $title, '', 'R');
|
||||
|
||||
$pdf->SetFont('','B',$default_font_size);
|
||||
|
||||
$posy+=6;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
|
||||
$pdf->SetFont('','B', $default_font_size);
|
||||
|
||||
if ($object->ref_supplier)
|
||||
{
|
||||
@@ -994,10 +989,22 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
|
||||
}
|
||||
|
||||
$posy+=2;
|
||||
$pdf->SetFont('','', $default_font_size -1);
|
||||
|
||||
$posy+=5;
|
||||
$posy+=6;
|
||||
if (! empty($conf->global->PDF_SHOW_PROJECT))
|
||||
{
|
||||
$object->fetch_projet();
|
||||
$pdf->SetXY($posx,$posy);
|
||||
if (! empty($object->project->ref))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
|
||||
$posy+=4;
|
||||
}
|
||||
}
|
||||
|
||||
$pdf->SetXY($posx,$posy);
|
||||
if (! empty($object->date_commande))
|
||||
{
|
||||
@@ -1011,7 +1018,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
}
|
||||
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
if (! empty($object->date_livraison)) $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,"day",false,$outputlangs,true), '', 'R');
|
||||
$usehourmin='day';
|
||||
if ( empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour';
|
||||
if (! empty($object->date_livraison)) $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,$usehourmin,false,$outputlangs,true), '', 'R');
|
||||
|
||||
$posy+=5;
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
@@ -1022,7 +1031,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
if ($showaddress)
|
||||
{
|
||||
// Sender properties
|
||||
$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
|
||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandlerInterface.php';
|
||||
|
||||
|
||||
@@ -1,4 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/syslog/logHandlerInterface.php
|
||||
* \ingroup syslog
|
||||
* \brief LogHandlerInterface
|
||||
*/
|
||||
|
||||
/**
|
||||
* LogHandlerInterface
|
||||
@@ -44,7 +65,7 @@ interface LogHandlerInterface
|
||||
/**
|
||||
* Return if logger active
|
||||
*
|
||||
* @return boolen True if active
|
||||
* @return boolean True if active
|
||||
*/
|
||||
public function isActive();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
|
||||
/**
|
||||
* Is the module active ?
|
||||
*
|
||||
* @return boolean
|
||||
* @return int
|
||||
*/
|
||||
public function isActive()
|
||||
{
|
||||
@@ -51,8 +51,13 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
|
||||
{
|
||||
if (empty($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH)) $conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH='/usr/share/php';
|
||||
set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
|
||||
$res = @include_once 'ChromePhp.class.php';
|
||||
|
||||
//print 'rrrrr'.get_include_path();
|
||||
$res = include_once('ChromePhp.php');
|
||||
if (! $res) $res=@include_once('ChromePhp.class.php');
|
||||
|
||||
restore_include_path();
|
||||
|
||||
if ($res)
|
||||
{
|
||||
return 1;
|
||||
@@ -77,10 +82,11 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
|
||||
|
||||
return array(
|
||||
array(
|
||||
'name' => $langs->trans('IncludePath'),
|
||||
'name' => $langs->trans('IncludePath','SYSLOG_CHROMEPHP_INCLUDEPATH'),
|
||||
'constant' => 'SYSLOG_CHROMEPHP_INCLUDEPATH',
|
||||
'default' => '/usr/share/php',
|
||||
'attr' => 'size="40"'
|
||||
'attr' => 'size="60"',
|
||||
'example' => DOL_DOCUMENT_ROOT.'/includes/chromephp'
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -88,24 +94,19 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
|
||||
/**
|
||||
* Return if configuration is valid
|
||||
*
|
||||
* @return boolean True if configuration ok
|
||||
* @return array Array of errors. Empty array if ok.
|
||||
*/
|
||||
public function checkConfiguration()
|
||||
{
|
||||
global $langs;
|
||||
global $langs,$conf;
|
||||
|
||||
$errors = array();
|
||||
|
||||
$oldinclude = get_include_path();
|
||||
set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH);
|
||||
|
||||
if (!file_exists('ChromePhp.class.php'))
|
||||
if (! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && ! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php'))
|
||||
{
|
||||
$errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php');
|
||||
$errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php or ChromePhp.php');
|
||||
}
|
||||
|
||||
set_include_path($oldinclude);
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
@@ -122,16 +123,18 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
|
||||
if (! empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) return; // Global option to disable output of this handler
|
||||
|
||||
//We check the configuration to avoid showing PHP warnings
|
||||
if (count($this->checkConfiguration())) return false;
|
||||
if (count($this->checkConfiguration()) > 0) return false;
|
||||
|
||||
try
|
||||
{
|
||||
// Warning ChromePHP must be into PHP include path. It is not possible to use into require_once() a constant from
|
||||
// database or config file because we must be able to log data before database or config file read.
|
||||
$oldinclude=get_include_path();
|
||||
set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH);
|
||||
include_once 'ChromePhp.class.php';
|
||||
set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
|
||||
$res = @include_once('ChromePhp.php');
|
||||
if (! $res) $res=@include_once('ChromePhp.class.php');
|
||||
set_include_path($oldinclude);
|
||||
|
||||
ob_start(); // To be sure headers are not flushed until all page is completely processed
|
||||
if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']);
|
||||
elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']);
|
||||
|
||||
@@ -45,11 +45,11 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
|
||||
/**
|
||||
* Is the module active ?
|
||||
*
|
||||
* @return boolean
|
||||
* @return int
|
||||
*/
|
||||
public function isActive()
|
||||
{
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
|
||||
/**
|
||||
* Return if configuration is valid
|
||||
*
|
||||
* @return boolean True if configuration ok
|
||||
* @return array Array of errors. Empty array if ok.
|
||||
*/
|
||||
public function checkConfiguration()
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
|
||||
/**
|
||||
* Is the module active ?
|
||||
*
|
||||
* @return boolean
|
||||
* @return int
|
||||
*/
|
||||
public function isActive()
|
||||
{
|
||||
@@ -53,7 +53,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
|
||||
restore_include_path();
|
||||
if ($res)
|
||||
{
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
@@ -61,7 +61,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
|
||||
print '<!-- FirePHP not available into PHP -->'."\n";
|
||||
}
|
||||
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
///**
|
||||
@@ -86,7 +86,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
|
||||
/**
|
||||
* Return if configuration is valid
|
||||
*
|
||||
* @return boolean True if configuration ok
|
||||
* @return array Array of errors. Empty array if ok.
|
||||
*/
|
||||
public function checkConfiguration()
|
||||
{
|
||||
|
||||
@@ -42,14 +42,14 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
|
||||
/**
|
||||
* Is the module active ?
|
||||
*
|
||||
* @return boolean
|
||||
* @return int
|
||||
*/
|
||||
public function isActive()
|
||||
{
|
||||
// This function does not exists on some ISP (Ex: Free in France)
|
||||
if (!function_exists('openlog')) return false;
|
||||
if (!function_exists('openlog')) return 0;
|
||||
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
|
||||
/**
|
||||
* Return if configuration is valid
|
||||
*
|
||||
* @return boolean True if configuration ok
|
||||
* @return array Array of errors. Empty array if ok.
|
||||
*/
|
||||
public function checkConfiguration()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user