rework an experimental module
This commit is contained in:
parent
c2d66a9e64
commit
5a3347104f
@ -178,7 +178,7 @@ if ($action == 'testtemplate' && $user->admin) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$object = new Facture($db);
|
||||
//$object->initAsSpecimen();
|
||||
$object->fetch(8);
|
||||
$object->fetch(18);
|
||||
//var_dump($object->lines);
|
||||
$ret = $printer->sendToPrinter($object, $templateid, 1);
|
||||
if ($ret == 0) {
|
||||
@ -263,15 +263,13 @@ if ($mode == 'config' && $user->admin) {
|
||||
|
||||
print $langs->trans("ReceiptPrinterDesc")."<br><br>\n";
|
||||
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans("Name").'</th>';
|
||||
print '<th>'.$langs->trans("Type").'</th>';
|
||||
print '<th>'.$langs->trans("Profile").'</th>';
|
||||
print '<th>'.$langs->trans("Parameters").'</th>';
|
||||
print '<th></th>';
|
||||
print '<th></th>';
|
||||
print '<th></th>';
|
||||
print "</tr>\n";
|
||||
$ret = $printer->listprinters();
|
||||
$nbofprinters = count($printer->listprinters);
|
||||
@ -290,8 +288,6 @@ if ($mode == 'config' && $user->admin) {
|
||||
print '<td>'.$printer->profileresprint.'</td>';
|
||||
print '<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line]['parameter'].'"></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '</tr>';
|
||||
} else {
|
||||
print '<td>'.$printer->listprinters[$line]['name'].'</td>';
|
||||
@ -301,13 +297,13 @@ if ($mode == 'config' && $user->admin) {
|
||||
// edit icon
|
||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=config&action=editprinter&printerid='.$printer->listprinters[$line]['rowid'].'">';
|
||||
print img_picto($langs->trans("Edit"), 'edit');
|
||||
print '</a></td>';
|
||||
print '</a>';
|
||||
// delete icon
|
||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=config&action=deleteprinter&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.$printer->listprinters[$line]['name'].'">';
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?mode=config&action=deleteprinter&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.$printer->listprinters[$line]['name'].'">';
|
||||
print img_picto($langs->trans("Delete"), 'delete');
|
||||
print '</a></td>';
|
||||
print '</a>';
|
||||
// test icon
|
||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=config&action=testprinter&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.$printer->listprinters[$line]['name'].'">';
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?mode=config&action=testprinter&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.$printer->listprinters[$line]['name'].'">';
|
||||
print img_picto($langs->trans("TestPrinter"), 'printer');
|
||||
print '</a></td>';
|
||||
print '</tr>';
|
||||
@ -323,8 +319,6 @@ if ($mode == 'config' && $user->admin) {
|
||||
print '<th>'.$langs->trans("Profile").'</th>';
|
||||
print '<th>'.$langs->trans("Parameters").'</th>';
|
||||
print '<th></th>';
|
||||
print '<th></th>';
|
||||
print '<th></th>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
@ -413,21 +407,19 @@ if ($mode == 'template' && $user->admin) {
|
||||
print '<td><textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line]['template'].'</textarea>';
|
||||
print '</td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
} else {
|
||||
print '<td>'.$printer->listprinterstemplates[$line]['name'].'</td>';
|
||||
print '<td>'.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).'</td>';
|
||||
// edit icon
|
||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=template&action=edittemplate&templateid='.$printer->listprinterstemplates[$line]['rowid'].'">';
|
||||
print img_picto($langs->trans("Edit"), 'edit');
|
||||
print '</a></td>';
|
||||
print '</a>';
|
||||
// delete icon
|
||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=template&action=deletetemplate&templateid='.$printer->listprinterstemplates[$line]['rowid'].'&templatename='.$printer->listprinterstemplates[$line]['name'].'">';
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?mode=template&action=deletetemplate&templateid='.$printer->listprinterstemplates[$line]['rowid'].'&templatename='.$printer->listprinterstemplates[$line]['name'].'">';
|
||||
print img_picto($langs->trans("Delete"), 'delete');
|
||||
print '</a></td>';
|
||||
print '</a>';
|
||||
// test icon
|
||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=template&action=testtemplate&templateid='.$printer->listprinterstemplates[$line]['rowid'].'&templatename='.$printer->listprinterstemplates[$line]['name'].'">';
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?mode=template&action=testtemplate&templateid='.$printer->listprinterstemplates[$line]['rowid'].'&templatename='.$printer->listprinterstemplates[$line]['name'].'">';
|
||||
print img_picto($langs->trans("TestPrinterTemplate"), 'printer');
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -442,8 +434,6 @@ if ($mode == 'template' && $user->admin) {
|
||||
print '<td><textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line]['template'].'</textarea>';
|
||||
print '</td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
|
||||
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
|
||||
} else {
|
||||
|
||||
@ -37,55 +37,65 @@
|
||||
* <dol_underline_2dots> </dol_underline_2dots> Underline with double line
|
||||
* <dol_emphasized> </dol_emphasized> Emphasized text
|
||||
* <dol_switch_colors> </dol_switch_colors> Print in white on black
|
||||
* <dol_print_barcode> Print barcode
|
||||
* <dol_print_barcode_customer_id> Print barcode customer id
|
||||
* <dol_set_print_width_57> Ticket print width of 57mm
|
||||
* <dol_cut_paper_full> Cut ticket completely
|
||||
* <dol_cut_paper_partial> Cut ticket partially
|
||||
* <dol_open_drawer> Open cash drawer
|
||||
* <dol_activate_buzzer> Activate buzzer
|
||||
*
|
||||
* Code which can be placed everywhere
|
||||
* <dol_print_barcode> Print barcode
|
||||
* <dol_print_qrcode> Print QR Code
|
||||
* <dol_print_date> Print date AAAA-MM-DD
|
||||
* <dol_print_date_time> Print date and time AAAA-MM-DD HH:MM:SS
|
||||
* <dol_print_year> Print Year
|
||||
* <dol_print_month_letters> Print month in letters (example : november)
|
||||
* <dol_print_month> Print month number
|
||||
* <dol_print_day> Print day number
|
||||
* <dol_print_day_letters> Print day number
|
||||
* <dol_print_table> Print table number (for restaurant, bar...)
|
||||
* <dol_print_cutlery> Print number of cutlery (for restaurant)
|
||||
* <dol_print_payment> Print payment method
|
||||
* <dol_print_logo> Print logo stored on printer. Example : <print_logo>32|32
|
||||
* <dol_print_logo_old> Print logo stored on printer. Must be followed by logo code. For old printers.
|
||||
* <dol_print_object_lines> Print object lines
|
||||
* <dol_print_object_tax> Print object total tax
|
||||
* <dol_print_object_local_tax> Print object local tax
|
||||
* <dol_print_object_total> Print object total
|
||||
* <dol_print_object_number> Print object number
|
||||
* <dol_print_object_number_unique> Print object number after validation
|
||||
* <dol_print_customer_firstname> Print customer firstname
|
||||
* <dol_print_customer_lastname> Print customer name
|
||||
* <dol_print_customer_mail> Print customer mail
|
||||
* <dol_print_customer_phone> Print customer phone
|
||||
* <dol_print_customer_mobile> Print customer mobile
|
||||
* <dol_print_customer_skype> Print customer skype
|
||||
* <dol_print_customer_tax_number> Print customer VAT number
|
||||
* <dol_print_customer_account_balance> Print customer account balance
|
||||
* <dol_print_vendor_lastname> Print vendor name
|
||||
* <dol_print_vendor_firstname> Print vendor firstname
|
||||
* <dol_print_vendor_mail> Print vendor mail
|
||||
* <dol_print_customer_points> Print customer points
|
||||
* <dol_print_object_points> Print number of points for this object
|
||||
* <dol_print_object_lines> Print object lines
|
||||
* <dol_print_object_tax> Print object total tax
|
||||
* <dol_print_object_local_tax> Print object local tax
|
||||
* <dol_print_object_total> Print object total
|
||||
* <dol_print_payment> Print payment method
|
||||
*
|
||||
* Conditional code at line start (if<EFBFBD>then Print)
|
||||
* Code which can be placed everywhere
|
||||
* <dol_value_date> Replaced by date AAAA-MM-DD
|
||||
* <dol_value_date_time> Replaced by date and time AAAA-MM-DD HH:MM:SS
|
||||
* <dol_value_year> Replaced by Year
|
||||
* <dol_value_month_letters> Replaced by month in letters (example : november)
|
||||
* <dol_value_month> Replaced by month number
|
||||
* <dol_value_day> Replaced by day number
|
||||
* <dol_value_day_letters> Replaced by day number
|
||||
* <dol_value_table> Replaced by table number (for restaurant, bar...)
|
||||
* <dol_value_cutlery> Replaced by number of cutlery (for restaurant)
|
||||
* <dol_object_id> Replaced by object id
|
||||
* <dol_object_ref> Replaced by object ref
|
||||
* <dol_value_customer_firstname> Replaced by customer firstname
|
||||
* <dol_value_customer_lastname> Replaced by customer name
|
||||
* <dol_value_customer_mail> Replaced by customer mail
|
||||
* <dol_value_customer_phone> Replaced by customer phone
|
||||
* <dol_value_customer_mobile> Replaced by customer mobile
|
||||
* <dol_value_customer_skype> Replaced by customer skype
|
||||
* <dol_value_customer_tax_number> Replaced by customer VAT number
|
||||
* <dol_value_customer_account_balance> Replaced by customer account balance
|
||||
* <dol_value_mysoc_name> Replaced by mysoc name
|
||||
* <dol_value_mysoc_address> Replaced by mysoc address
|
||||
* <dol_value_mysoc_zip> Replaced by mysoc zip
|
||||
* <dol_value_mysoc_town> Replaced by mysoc town
|
||||
* <dol_value_mysoc_country> Replaced by mysoc country
|
||||
* <dol_value_mysoc_idprof1> Replaced by mysoc idprof1
|
||||
* <dol_value_mysoc_idprof2> Replaced by mysoc idprof2
|
||||
* <dol_value_mysoc_idprof3> Replaced by mysoc idprof3
|
||||
* <dol_value_mysoc_idprof4> Replaced by mysoc idprof4
|
||||
* <dol_value_mysoc_idprof5> Replaced by mysoc idprof5
|
||||
* <dol_value_mysoc_idprof6> Replaced by mysoc idprof6
|
||||
* <dol_value_vendor_lastname> Replaced by vendor name
|
||||
* <dol_value_vendor_firstname> Replaced by vendor firstname
|
||||
* <dol_value_vendor_mail> Replaced by vendor mail
|
||||
* <dol_value_customer_points> Replaced by customer points
|
||||
* <dol_value_object_points> Replaced by number of points for this object
|
||||
*
|
||||
* Conditional code at line start (if then Print)
|
||||
* <dol_print_if_customer> Print the line IF a customer is affected to the object
|
||||
* <dol_print_if_vendor> Print the line IF a vendor is affected to the object
|
||||
* <dol_print_if_happy_hour> Print the line IF Happy Hour
|
||||
* <dol_print_if_num_object_unique> Print the line IF object is validated
|
||||
* <dol_print_if_num_object_unique> Print the line IF object is validated
|
||||
* <dol_print_if_customer_points> Print the line IF customer points > 0
|
||||
* <dol_print_if_object_points> Print the line IF points of the object > 0
|
||||
* <dol_print_if_object_points> Print the line IF points of the object > 0
|
||||
* <dol_print_if_customer_tax_number> Print the line IF customer has vat number
|
||||
* <dol_print_if_customer_account_balance_positive> Print the line IF customer balance > 0
|
||||
*
|
||||
@ -116,6 +126,9 @@ class dolReceiptPrinter extends Printer
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/*
|
||||
* @var string[] array of tags
|
||||
*/
|
||||
public $tags;
|
||||
public $printer;
|
||||
public $template;
|
||||
@ -130,8 +143,6 @@ class dolReceiptPrinter extends Printer
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -142,6 +153,7 @@ class dolReceiptPrinter extends Printer
|
||||
$this->db=$db;
|
||||
$this->tags = array(
|
||||
'dol_line_feed',
|
||||
'dol_line_feed_reverse',
|
||||
'dol_align_left',
|
||||
'dol_align_center',
|
||||
'dol_align_right',
|
||||
@ -162,8 +174,6 @@ class dolReceiptPrinter extends Printer
|
||||
'/dol_emphasized',
|
||||
'dol_switch_colors',
|
||||
'/dol_switch_colors',
|
||||
'dol_print_barcode',
|
||||
'dol_print_barcode_customer_id',
|
||||
'dol_set_print_width_57',
|
||||
'dol_cut_paper_full',
|
||||
'dol_cut_paper_partial',
|
||||
@ -171,39 +181,52 @@ class dolReceiptPrinter extends Printer
|
||||
//'dol_activate_buzzer',
|
||||
'dol_print_text',
|
||||
'dol_print_qrcode',
|
||||
'dol_print_date',
|
||||
'dol_print_date_time',
|
||||
'dol_print_year',
|
||||
'dol_print_month_letters',
|
||||
'dol_print_month',
|
||||
'dol_print_day',
|
||||
'dol_print_day_letters',
|
||||
'dol_print_table',
|
||||
'dol_print_cutlery',
|
||||
'dol_print_barcode',
|
||||
'dol_value_date',
|
||||
'dol_value_date_time',
|
||||
'dol_value_year',
|
||||
'dol_value_month_letters',
|
||||
'dol_value_month',
|
||||
'dol_value_day',
|
||||
'dol_value_day_letters',
|
||||
'dol_value_table',
|
||||
'dol_value_cutlery',
|
||||
'dol_print_payment',
|
||||
'dol_print_logo',
|
||||
'dol_print_logo_old',
|
||||
'dol_print_object_id',
|
||||
'dol_print_object_ref',
|
||||
'dol_value_object_id',
|
||||
'dol_value_object_ref',
|
||||
'dol_print_object_lines',
|
||||
'dol_print_object_tax',
|
||||
'dol_print_object_local_tax',
|
||||
'dol_print_object_total',
|
||||
'dol_print_object_number',
|
||||
'dol_print_object_number_unique',
|
||||
'dol_print_customer_firstname',
|
||||
'dol_print_customer_lastname',
|
||||
'dol_print_customer_mail',
|
||||
'dol_print_customer_phone',
|
||||
'dol_print_customer_mobile',
|
||||
'dol_print_customer_skype',
|
||||
'dol_print_customer_tax_number',
|
||||
'dol_print_customer_account_balance',
|
||||
'dol_print_vendor_lastname',
|
||||
'dol_print_vendor_firstname',
|
||||
'dol_print_vendor_mail',
|
||||
'dol_print_customer_points',
|
||||
'dol_print_object_points',
|
||||
'dol_value_customer_firstname',
|
||||
'dol_value_customer_lastname',
|
||||
'dol_value_customer_mail',
|
||||
'dol_value_customer_phone',
|
||||
'dol_value_customer_mobile',
|
||||
'dol_value_customer_skype',
|
||||
'dol_value_customer_tax_number',
|
||||
'dol_value_customer_account_balance',
|
||||
'dol_value_mysoc_name',
|
||||
'dol_value_mysoc_address',
|
||||
'dol_value_mysoc_zip',
|
||||
'dol_value_mysoc_town',
|
||||
'dol_value_mysoc_country',
|
||||
'dol_value_mysoc_idprof1',
|
||||
'dol_value_mysoc_idprof2',
|
||||
'dol_value_mysoc_idprof3',
|
||||
'dol_value_mysoc_idprof4',
|
||||
'dol_value_mysoc_idprof5',
|
||||
'dol_value_mysoc_idprof6',
|
||||
'dol_value_mysoc_tva_intra',
|
||||
'dol_value_mysoc_capital',
|
||||
'dol_value_vendor_lastname',
|
||||
'dol_value_vendor_firstname',
|
||||
'dol_value_vendor_mail',
|
||||
'dol_value_customer_points',
|
||||
'dol_value_object_points',
|
||||
'dol_print_if_customer',
|
||||
'dol_print_if_vendor',
|
||||
'dol_print_if_happy_hour',
|
||||
@ -328,7 +351,7 @@ class dolReceiptPrinter extends Printer
|
||||
1 => $langs->trans('CONNECTOR_DUMMY'),
|
||||
2 => $langs->trans('CONNECTOR_FILE_PRINT'),
|
||||
3 => $langs->trans('CONNECTOR_NETWORK_PRINT'),
|
||||
4 => $langs->trans('CONNECTOR_WINDOWS_PRINT')
|
||||
4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'),
|
||||
);
|
||||
|
||||
$this->resprint = Form::selectarray($htmlname, $options, $selected);
|
||||
@ -353,7 +376,7 @@ class dolReceiptPrinter extends Printer
|
||||
1 => $langs->trans('PROFILE_SIMPLE'),
|
||||
2 => $langs->trans('PROFILE_EPOSTEP'),
|
||||
3 => $langs->trans('PROFILE_P822D'),
|
||||
4 => $langs->trans('PROFILE_STAR')
|
||||
4 => $langs->trans('PROFILE_STAR'),
|
||||
);
|
||||
|
||||
$this->profileresprint = Form::selectarray($htmlname, $options, $selected);
|
||||
@ -502,6 +525,7 @@ class dolReceiptPrinter extends Printer
|
||||
$this->printer->text("Hello World!\n");
|
||||
$testStr = "1234567890";
|
||||
$this->printer->barcode($testStr);
|
||||
//$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1);
|
||||
$this->printer->text("Most simple example\n");
|
||||
$this->printer->feed();
|
||||
$this->printer->cut();
|
||||
@ -525,35 +549,48 @@ class dolReceiptPrinter extends Printer
|
||||
*/
|
||||
public function sendToPrinter($object, $templateid, $printerid)
|
||||
{
|
||||
global $conf, $mysoc;
|
||||
global $conf, $mysoc, $langs;
|
||||
$error = 0;
|
||||
$ret = $this->loadTemplate($templateid);
|
||||
|
||||
// tags a remplacer par leur valeur avant de parser
|
||||
$this->template = str_replace('<dol_print_object_id>', $object->id, $this->template);
|
||||
$this->template = str_replace('<dol_print_object_ref>', $object->ref, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_firstname>', $object->customer_firstname, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_lastname>', $object->customer_lastname, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_mail>', $object->customer_mail, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_phone>', $object->customer_phone, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_mobile>', $object->customer_mobile, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_skype>', $object->customer_skype, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_tax_number>', $object->customer_tax_number, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_account_balance>', $object->customer_account_balance, $this->template);
|
||||
$this->template = str_replace('<dol_print_customer_points>', $object->customer_points, $this->template);
|
||||
$this->template = str_replace('<dol_print_object_points>', $object->object_points, $this->template);
|
||||
$this->template = str_replace('<dol_print_vendor_firstname>', $object->vendor_firstname, $this->template);
|
||||
$this->template = str_replace('<dol_print_vendor_lastname>', $object->vendor_lastname, $this->template);
|
||||
$this->template = str_replace('<dol_print_vendor_mail>', $object->vendor_mail, $this->template);
|
||||
$this->template = str_replace('<dol_print_date>', $object->date, $this->template);
|
||||
$this->template = str_replace('<dol_print_date_time>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_print_year>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_print_month_letters>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_print_month>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_print_day>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_print_day_letters>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_print_table>', $object->table, $this->template);
|
||||
$this->template = str_replace('<dol_print_cutlery>', $object->cutlery, $this->template);
|
||||
// tags a remplacer par leur valeur avant de parser (dol_value_xxx)
|
||||
$this->template = str_replace('<dol_value_object_id>', $object->id, $this->template);
|
||||
$this->template = str_replace('<dol_value_object_ref>', $object->ref, $this->template);
|
||||
$this->template = str_replace('<dol_value_object_points>', $object->points, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_firstname>', $object->customer_firstname, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_lastname>', $object->customer_lastname, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_mail>', $object->customer_mail, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_phone>', $object->customer_phone, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_mobile>', $object->customer_mobile, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_skype>', $object->customer_skype, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_tax_number>', $object->customer_tax_number, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_account_balance>', $object->customer_account_balance, $this->template);
|
||||
$this->template = str_replace('<dol_value_customer_points>', $object->customer_points, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_name>', $mysoc->name, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_address>', $mysoc->address, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_zip>', $mysoc->zip, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_town>', $mysoc->town, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_country>', $mysoc->country, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_idprof1>', $mysoc->idprof1, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_idprof2>', $mysoc->idprof2, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_idprof3>', $mysoc->idprof3, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_idprof4>', $mysoc->idprof4, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_idprof5>', $mysoc->idprof5, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_idprof6>', $mysoc->idprof6, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_tva_intra>', $mysoc->tva_intra, $this->template);
|
||||
$this->template = str_replace('<dol_value_mysoc_capital>', $mysoc->capital, $this->template);
|
||||
$this->template = str_replace('<dol_value_vendor_firstname>', $object->vendor_firstname, $this->template);
|
||||
$this->template = str_replace('<dol_value_vendor_lastname>', $object->vendor_lastname, $this->template);
|
||||
$this->template = str_replace('<dol_value_vendor_mail>', $object->vendor_mail, $this->template);
|
||||
$this->template = str_replace('<dol_value_date>', $object->date, $this->template);
|
||||
$this->template = str_replace('<dol_value_date_time>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_value_year>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_value_month_letters>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_value_month>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_value_day>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_value_day_letters>', $object->date_time, $this->template);
|
||||
$this->template = str_replace('<dol_value_table>', $object->table, $this->template);
|
||||
$this->template = str_replace('<dol_value_cutlery>', $object->cutlery, $this->template);
|
||||
|
||||
// parse template
|
||||
$p = xml_parser_create();
|
||||
@ -563,7 +600,7 @@ class dolReceiptPrinter extends Printer
|
||||
//print '<pre>'.print_r($vals, true).'</pre>';
|
||||
// print ticket
|
||||
$level = 0;
|
||||
$nbcaractbyline = 47;
|
||||
$nbcharactbyline = 48;
|
||||
$ret = $this->initPrinter($printerid);
|
||||
if ($ret>0) {
|
||||
setEventMessages($this->error, $this->errors, 'errors');
|
||||
@ -577,15 +614,45 @@ class dolReceiptPrinter extends Printer
|
||||
break;
|
||||
case 'DOL_PRINT_OBJECT_LINES':
|
||||
foreach ($object->lines as $line) {
|
||||
$spacestoadd = $nbcaractbyline - strlen($line->ref) - strlen(price($line->total_ttc, 'MT'));
|
||||
//var_dump($line);
|
||||
$spacestoadd = $nbcharactbyline - strlen($line->ref)- strlen($line->qty) - 10 - 1;
|
||||
$spaces = str_repeat(' ', $spacestoadd);
|
||||
$this->printer->text($line->ref.$spaces.price($line->total_ttc, 'MT')."\n");
|
||||
//var_dump($line->ref);
|
||||
$this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
|
||||
$this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n");
|
||||
}
|
||||
break;
|
||||
case 'DOL_PRINT_OBJECT_TAX':
|
||||
//var_dump($object);
|
||||
$vatarray = array();
|
||||
foreach ($object->lines as $line) {
|
||||
$vatarray[$line->tva_tx] += $line->total_tva;
|
||||
}
|
||||
foreach($vatarray as $vatkey => $vatvalue) {
|
||||
$spacestoadd = $nbcharactbyline - strlen($vatkey)- 12;
|
||||
$spaces = str_repeat(' ', $spacestoadd);
|
||||
$this->printer->text($spaces. $vatkey.'% '.str_pad(price($vatvalue, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
|
||||
}
|
||||
break;
|
||||
case 'DOL_PRINT_OBJECT_TOTAL':
|
||||
$title = $langs->trans('TotalHT');
|
||||
$spacestoadd = $nbcharactbyline - strlen($title) - 10;
|
||||
$spaces = str_repeat(' ', $spacestoadd);
|
||||
$this->printer->text($title.$spaces.str_pad(price($object->total_ht, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
|
||||
$title = $langs->trans('TotalVAT');
|
||||
$spacestoadd = $nbcharactbyline - strlen($title) - 10;
|
||||
$spaces = str_repeat(' ', $spacestoadd);
|
||||
$this->printer->text($title.$spaces.str_pad(price($object->total_tva, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
|
||||
$title = $langs->trans('TotalTTC');
|
||||
$spacestoadd = $nbcharactbyline - strlen($title) - 10;
|
||||
$spaces = str_repeat(' ', $spacestoadd);
|
||||
$this->printer->text($title.$spaces.str_pad(price($object->total_ttc, 'MT'), 10, ' ', STR_PAD_LEFT)."\n");
|
||||
break;
|
||||
case 'DOL_LINE_FEED':
|
||||
$this->printer->feed();
|
||||
break;
|
||||
case 'DOL_LINE_FEED_REVERSE':
|
||||
$this->printer->feedReverse();
|
||||
break;
|
||||
case 'DOL_ALIGN_CENTER':
|
||||
$this->printer->setJustification(Printer::JUSTIFY_CENTER);
|
||||
break;
|
||||
@ -603,22 +670,22 @@ class dolReceiptPrinter extends Printer
|
||||
break;
|
||||
case 'DOL_PRINT_BARCODE':
|
||||
// $vals[$tplline]['value'] -> barcode($content, $type)
|
||||
$this->printer->barcode($object->barcode);
|
||||
// var_dump($vals[$tplline]['value']);
|
||||
try {
|
||||
$this->printer->barcode($vals[$tplline]['value']);
|
||||
} catch (Exception $e) {
|
||||
$this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value'];
|
||||
$error++;
|
||||
}
|
||||
break;
|
||||
case 'DOL_PRINT_LOGO':
|
||||
// $vals[$tplline]['value'] -> barcode($content, $type)
|
||||
$img = EscposImage::load(DOL_DATA_ROOT .'/mycompany/logos/'.$mysoc->logo);
|
||||
$this->printer->graphics($img);
|
||||
break;
|
||||
case 'DOL_PRINT_LOGO_OLD':
|
||||
// $vals[$tplline]['value'] -> barcode($content, $type)
|
||||
$img = EscposImage::load(DOL_DATA_ROOT .'/mycompany/logos/'.$mysoc->logo);
|
||||
$this->printer->bitImage($img);
|
||||
break;
|
||||
case 'DOL_PRINT_BARCODE_CUSTOMER_ID':
|
||||
// $vals[$tplline]['value'] -> barcode($content, $type)
|
||||
$this->printer->barcode($object->customer_id);
|
||||
break;
|
||||
case 'DOL_PRINT_QRCODE':
|
||||
// $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model)
|
||||
$this->printer->qrcode($vals[$tplline]['value']);
|
||||
@ -631,19 +698,16 @@ class dolReceiptPrinter extends Printer
|
||||
break;
|
||||
case 'DOL_USE_FONT_A':
|
||||
$this->printer->setFont(Printer::FONT_A);
|
||||
$this->printer->text($vals[$tplline]['value']);
|
||||
break;
|
||||
case 'DOL_USE_FONT_B':
|
||||
$this->printer->setFont(Printer::FONT_B);
|
||||
$this->printer->text($vals[$tplline]['value']);
|
||||
break;
|
||||
case 'DOL_USE_FONT_C':
|
||||
$this->printer->setFont(Printer::FONT_C);
|
||||
$this->printer->text($vals[$tplline]['value']);
|
||||
break;
|
||||
default:
|
||||
$this->printer->text($vals[$tplline]['tag']);
|
||||
$this->printer->text($vals[$tplline]['value']);
|
||||
$html.= nl2br($vals[$tplline]['value']);
|
||||
$this->errors[] = 'UnknowTag: <'.strtolower($vals[$tplline]['tag']).'>';
|
||||
$error++;
|
||||
break;
|
||||
|
||||
@ -30,9 +30,9 @@ class ApiPrintConnector implements PrintConnector
|
||||
/**
|
||||
* Construct new connector
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $printerId
|
||||
* @param string $apiToken
|
||||
* @param string $host Host
|
||||
* @param string $printerId Printer Id
|
||||
* @param string $apiToken Api Token
|
||||
*/
|
||||
public function __construct($host, $printerId, $apiToken)
|
||||
{
|
||||
@ -57,6 +57,7 @@ class ApiPrintConnector implements PrintConnector
|
||||
/**
|
||||
* Finish using this print connector (close file, socket, send
|
||||
* accumulated output, etc).
|
||||
* @return void
|
||||
*/
|
||||
public function finalize()
|
||||
{
|
||||
@ -94,6 +95,7 @@ class ApiPrintConnector implements PrintConnector
|
||||
* Write data to the print connector.
|
||||
*
|
||||
* @param string $data The data to write
|
||||
* @return void
|
||||
*/
|
||||
public function write($data)
|
||||
{
|
||||
|
||||
@ -2093,7 +2093,6 @@ class Product extends CommonObject
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
|
||||
unset($this->oldcopy);
|
||||
|
||||
if ($this->db->num_rows($resql) > 0) {
|
||||
|
||||
@ -269,7 +269,6 @@ if (empty($reshook))
|
||||
$resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $object->product_fourn_price_id);
|
||||
// Insert a new extrafields row, if none exists
|
||||
if ($db->num_rows($resql) != 1) {
|
||||
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields (fk_object, ";
|
||||
foreach ($extrafield_values as $key => $value) {
|
||||
$sql .= str_replace('options_', '', $key) . ', ';
|
||||
@ -291,7 +290,7 @@ if (empty($reshook))
|
||||
|
||||
// Execute the sql command from above
|
||||
$db->query($sql);
|
||||
|
||||
|
||||
$newprice = price2num(GETPOST("price", "alpha"));
|
||||
|
||||
if ($conf->multicurrency->enabled)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user