This commit is contained in:
Laurent Destailleur 2013-07-13 21:14:05 +02:00
parent 0f1c4032ab
commit 3a9ffb19c3
18 changed files with 117 additions and 83 deletions

View File

@ -295,14 +295,14 @@ if ($id > 0 || ! empty($ref))
*/
$param.='&account='.$object->id.'&vline='.$vline;
// Confirmation delete
if ($action == 'delete')
{
$text=$langs->trans('ConfirmDeleteTransaction');
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"),$langs->trans('DeleteTransaction'),$text,'confirm_delete');
if ($ret == 'html') print '<br>';
}
// Confirmation delete
if ($action == 'delete')
{
$text=$langs->trans('ConfirmDeleteTransaction');
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;rowid='.GETPOST("rowid"),$langs->trans('DeleteTransaction'),$text,'confirm_delete');
if ($ret == 'html') print '<br>';
}
// Define transaction list navigation string
print '<form action="'.$_SERVER["PHP_SELF"].'" name="newpage" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';

View File

@ -1553,4 +1553,31 @@ function pdf_getLinkedObjects($object,$outputlangs)
return $linkedobjects;
}
/**
* Return dimensions to use for images onto PDF
*
* @param string $realpath Full path to photo file to use
* @return array Height/Width to use to output image (in pixel)
*/
function pdf_getHeightForImage($realpath)
{
$maxheight=12; $maxwidth=16;
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$tmp=dol_getImageSize($realpath);
if ($tmp['height'])
{
$width=(int) round($maxheight*$tmp['width']/$tmp['height']);
if ($width > $maxwidth)
{
$height=(int) round($height*$maxwidth/$width);
$width=$maxwidth;
}
else
{
$height=$maxheight;
}
}
return array('width'=>$width,'height'=>$height);
}
?>

View File

@ -282,15 +282,15 @@ class pdf_azur extends ModelePDFPropales
$showpricebeforepagebreak=1;
$pdf->startTransaction();
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
}
else
{
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
}
else
{
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
}
$pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
@ -298,13 +298,13 @@ class pdf_azur extends ModelePDFPropales
$pageposafter=$pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
}
else
{
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
}
else
{
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
}
$pageposafter=$pdf->getPage();
@ -343,53 +343,60 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
// Photo
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
$curX = $this->posxpicture-1;
if ($object->lines[$i]->fk_product)
{
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
$pdir = get_exdir($object->lines[$i]->fk_product,2) . $object->lines[$i]->fk_product ."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
// Photo
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
$curX = $this->posxpicture-1;
if ($object->lines[$i]->fk_product)
{
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
$pdir = get_exdir($object->lines[$i]->fk_product,2) . $object->lines[$i]->fk_product ."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
$realpath='';
if ($object->ref == 'SPECIMEN')
{
$realpath = DOL_DOCUMENT_ROOT.'/theme/common/nophoto.jpg';
}
else
{
foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
{
if ($obj['photo_vignette'])
{
$filename='thumbs/'.$obj['photo_vignette'];
}
else
{
$filename=$obj['photo'];
}
{
foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
{
if ($obj['photo_vignette'])
{
$filename='thumbs/'.$obj['photo_vignette'];
}
else
{
$filename=$obj['photo'];
}
$realpath = $dir.$filename;
break;
}
break;
}
}
if (!empty($realpath))
{
if (!empty($realpath))
{
//$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$tmp=pdf_getHeightForImage($realpath);
//var_dump($tmp['height']);exit;
$pdf->Image($realpath, $curX, $curY-1, $tmp['width'], $tmp['height'],'','','',2, 300); // Use 300 dpi
//var_dump(constant('PDF_IMAGE_SCALE_RATIO'));var_dump($pdf->getImageScale());var_dump($tmp['width']);var_dump($pdf->pixelsToUnits($tmp['width']));exit;
// measures 1/72 of an inch, i.e. approximately 0.0139 inch or 25.4/72 = 0.3528 mm
var_dump($this->page_largeur);exit;
//var_dump(tmp['height']);exit;
$pdf->Line($this->posxtva,10,$this->posxtva+0.5,10);
$pdf->Image($realpath, $this->posxtva, 10, $tmp['width'], $tmp['height'],'','','',2,0); // Use 300 dpi
$pdf->Line($this->posxtva+$pdf->pixelsToUnits($tmp['width']),10,$this->posxtva+$pdf->pixelsToUnits($tmp['width'])+0.5,10);
$pdf->Image($realpath, $curX + ($this->posxtva-$this->posxpicture-($pdf->pixelsToUnits($tmp['width'])))/2, $curY-1, $tmp['width'], $tmp['height'],'','','',2, 300); // Use 300 dpi
//$nexY += 7; // +7 for height = 12
$nexY += round($tmp['height'] / 12 * 7);
//var_dump($nexY);exit;
$nexY += round($pdf->pixelsToUnits($tmp['height']));
//var_dump($nexY);exit;
}
}
}
}
}
// VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
@ -1073,15 +1080,15 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
}
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxpicture-1, $tab_top+1);
$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
}
}
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxpicture-1, $tab_top+1);
$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
}
}
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{

View File

@ -60,7 +60,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
if (! isset($argv[3]) || ! $argv[3]) {
print "Usage: ".$script_file." bank_ref [bank_receipt_number|all] (csv|tsv|excel|excel2007) [lang=xx_XX]\n";
@ -177,7 +177,7 @@ $array_export_TypeFields=array(
$listofnum="";
if (! empty($num) && $num != "all")
{
$listofnum.="'";
$listofnum.="'";
$arraynum=explode(',',$num);
foreach($arraynum as $val)
{

View File

@ -60,7 +60,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
$fname = DOL_DATA_ROOT.'/export-contacts.xls';

View File

@ -57,7 +57,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails

View File

@ -66,7 +66,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
$now=dol_now('tzserver');
$duration_value=isset($argv[2])?$argv[2]:'none';

View File

@ -66,7 +66,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
$now=dol_now('tzserver');
$duration_value=isset($argv[2])?$argv[2]:'none';

View File

@ -67,7 +67,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
$now=dol_now('tzserver');
$duration_value=isset($argv[3])?$argv[3]:'none';

View File

@ -66,7 +66,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
$now=dol_now('tzserver');
$duration_value=isset($argv[2])?$argv[2]:'none';

View File

@ -57,7 +57,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
// Check parameters
if (! isset($argv[1]))

View File

@ -52,7 +52,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
if (! isset($argv[1]) || ! $argv[1]) {
print "Usage: $script_file now\n";

View File

@ -57,7 +57,7 @@ $forcecommit=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
// List of fields to get from LDAP
$required_fields = array(

View File

@ -55,7 +55,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
/*
if (! $conf->global->LDAP_SYNCHRO_ACTIVE)

View File

@ -57,7 +57,7 @@ $forcecommit=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
// List of fields to get from LDAP
$required_fields = array(

View File

@ -55,7 +55,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
/*
if (! $conf->global->LDAP_SYNCHRO_ACTIVE)

View File

@ -55,7 +55,7 @@ $forcecommit=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
// List of fields to get from LDAP
$required_fields = array(

View File

@ -51,7 +51,7 @@ $error=0;
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv));
dol_syslog($script_file." launched with arg ".join(',',$argv));
$datetimeprev = dol_now();