Beispiel #1
0
/**
 *	Output line description into PDF
 *
 *  @param  PDF				$pdf               PDF object
 *	@param	Object			$object				Object
 *	@param	int				$i					Current line number
 *  @param  Translate		$outputlangs		Object lang for output
 *  @param  int				$w					Width
 *  @param  int				$h					Height
 *  @param  int				$posx				Pos x
 *  @param  int				$posy				Pos y
 *  @param  int				$hideref       		Hide reference
 *  @param  int				$hidedesc           Hide description
 * 	@param	int				$issupplierline		Is it a line for a supplier object ?
 * 	@return	string
 */
function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
{
    global $db, $conf, $langs, $hookmanager;
    $reshook = 0;
    //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
    if (is_object($hookmanager)) {
        $special_code = $object->lines[$i]->special_code;
        if (!empty($object->lines[$i]->fk_parent_line)) {
            $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
        }
        $parameters = array('pdf' => $pdf, 'i' => $i, 'outputlangs' => $outputlangs, 'w' => $w, 'h' => $h, 'posx' => $posx, 'posy' => $posy, 'hideref' => $hideref, 'hidedesc' => $hidedesc, 'issupplierline' => $issupplierline, 'special_code' => $special_code);
        $action = '';
        $reshook = $hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action);
        // Note that $action and $object may have been modified by some hooks
        if (!empty($hookmanager->resPrint)) {
            return $hookmanager->resPrint;
        }
    }
    if (empty($reshook)) {
        $labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
        // Description
        $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J', true);
        return $labelproductservice;
    }
    return '';
}
Beispiel #2
0
/**
 *	Output line description into PDF
 *  @param      pdf                 PDF object
 *	@param		object				Object
 *	@param		i					Current line number
 *  @param    	outputlang			Object lang for output
 *  @param      w
 *  @param      h
 *  @param      posx
 *  @param      posy
 *  @param    	hideref       		Hide reference
 *  @param      hidedesc            Hide description
 * 	@param		issupplierline		Is it a line for a supplier object ?
 */
function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
{
    global $db, $conf, $langs;
    if (!empty($object->hooks) && ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) || !empty($object->lines[$i]->fk_parent_line))) {
        $special_code = $object->lines[$i]->special_code;
        if (!empty($object->lines[$i]->fk_parent_line)) {
            $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
        }
        foreach ($object->hooks as $hook) {
            if (method_exists($hook['modules'][$special_code], 'pdf_writelinedesc')) {
                return $hook['modules'][$special_code]->pdf_writelinedesc($pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref, $hidedesc, $issupplierline);
            }
        }
    } else {
        $labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
        // Description
        $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1);
        return $labelproductservice;
    }
}
Beispiel #3
0
    /**
     * testPdfDocGetLineDesc
     *
     * @return void
     */
    public function testPdfDocGetLineDesc()
    {
    	global $conf,$user,$langs,$db;
		$conf=$this->savconf;
		$user=$this->savuser;
		$langs=$this->savlangs;
		$db=$this->savdb;

		$localobject=new Facture($this->savdb);
		$localobject->initAsSpecimen();
		$localobject->lines=array();
		$localobject->lines[0]->fk_product=1;
		$localobject->lines[0]->label='Label 1';
		$localobject->lines[0]->desc="This is a description with a é accent\n(Country of origin: France)";

    	$result=pdf_getlinedesc($localobject,0,$langs);
    	print __METHOD__." result=".$result."\n";
    	$this->assertEquals($result,"PIDRESS - Label 1<br>This is a description with a &eacute; accent<br>(Country of origin: France)");

    	$result=doc_getlinedesc($localobject->lines[0],$langs);
    	print __METHOD__." result=".$result."\n";
    	$this->assertEquals($result,"PIDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)");
    }
Beispiel #4
0
 /**
  * testPdfDocGetLineDesc
  *
  * @return void
  */
 public function testPdfDocGetLineDesc()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localproduct = new Product($this->savdb);
     $localproduct->fetch(0, 'PIDRESS');
     $product_id = $localproduct->id;
     if ($product_id <= 0) {
         print "\n" . __METHOD__ . " A product with ref PIDRESS must exists into database";
         die;
     }
     $localobject = new Facture($this->savdb);
     $localobject->initAsSpecimen();
     $localobject->lines = array();
     $localobject->lines[0] = new FactureLigne($this->savdb);
     $localobject->lines[0]->fk_product = $product_id;
     $localobject->lines[0]->label = 'Label 1';
     $localobject->lines[0]->desc = "This is a description with a é accent\n(Country of origin: France)";
     $result = pdf_getlinedesc($localobject, 0, $langs);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertEquals($result, "PIDRESS - Label 1<br>This is a description with a &eacute; accent<br>(Country of origin: France)");
     $result = doc_getlinedesc($localobject->lines[0], $langs);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertEquals($result, "PIDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)");
 }