/** * 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 é 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)"); }
/** * Define array with couple substitution key => substitution value * * @param array $line Array of lines * @param Translate $outputlangs Lang object to use for output * @return array Return substitution array */ function get_substitutionarray_lines($line, $outputlangs) { global $conf; return array('line_fulldesc' => doc_getlinedesc($line, $outputlangs), 'line_product_ref' => $line->product_ref, 'line_product_label' => $line->product_label, 'line_desc' => $line->desc, 'line_vatrate' => vatrate($line->tva_tx, true, $line->info_bits), 'line_up' => price($line->subprice, 0, $outputlangs), 'line_qty' => $line->qty, 'line_discount_percent' => $line->remise_percent ? $line->remise_percent . '%' : '', 'line_price_ht' => price($line->total_ht, 0, $outputlangs), 'line_price_ttc' => price($line->total_ttc, 0, $outputlangs), 'line_price_vat' => price($line->total_tva, 0, $outputlangs), 'line_date_start' => $line->date_start, 'line_date_end' => $line->date_end); }
/** * Define array with couple substitution key => substitution value * * @param array $line Array of lines * @param Translate $outputlangs Lang object to use for output * @return array Substitution array */ function get_substitutionarray_shipment_lines($line, $outputlangs) { global $conf; dol_include_once('/core/lib/product.lib.php'); return array('line_fulldesc' => doc_getlinedesc($line, $outputlangs), 'line_product_ref' => $line->product_ref, 'line_product_label' => $line->product_label, 'line_desc' => $line->desc, 'line_vatrate' => vatrate($line->tva_tx, true, $line->info_bits), 'line_up' => price($line->subprice), 'line_qty' => $line->qty, 'line_qty_shipped' => $line->qty_shipped, 'line_qty_asked' => $line->qty_asked, 'line_discount_percent' => $line->remise_percent ? $line->remise_percent . '%' : '', 'line_price_ht' => price($line->total_ht), 'line_price_ttc' => price($line->total_ttc), 'line_price_vat' => price($line->total_tva), 'line_weight' => empty($line->weight) ? '' : $line->weight * $line->qty_shipped . ' ' . measuring_units_string($line->weight_units, 'weight'), 'line_length' => empty($line->length) ? '' : $line->length * $line->qty_shipped . ' ' . measuring_units_string($line->length_units, 'size'), 'line_surface' => empty($line->surface) ? '' : $line->surface * $line->qty_shipped . ' ' . measuring_units_string($line->surface_units, 'surface'), 'line_volume' => empty($line->volume) ? '' : $line->volume * $line->qty_shipped . ' ' . measuring_units_string($line->volume_units, 'volume')); }
/** * 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 é 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)"); }