wip template edit
This commit is contained in:
parent
5c725aceb8
commit
4a67a94704
@ -249,15 +249,15 @@ if ($mode == 'config' && $user->admin)
|
|||||||
print '<td>'.$langs->trans($connector).'</td>';
|
print '<td>'.$langs->trans($connector).'</td>';
|
||||||
print '<td>'.$printer->listprinters[$line]['parameter'].'</td>';
|
print '<td>'.$printer->listprinters[$line]['parameter'].'</td>';
|
||||||
// edit icon
|
// edit icon
|
||||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?action=editprinter&printerid='.$printer->listprinters[$line]['rowid'].'">';
|
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=config&action=editprinter&printerid='.$printer->listprinters[$line]['rowid'].'">';
|
||||||
print img_picto($langs->trans("Edit"),'edit');
|
print img_picto($langs->trans("Edit"),'edit');
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
// delete icon
|
// delete icon
|
||||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?action=deleteprinter&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.$printer->listprinters[$line]['name'].'">';
|
print '<td><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 img_picto($langs->trans("Delete"),'delete');
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
// test icon
|
// test icon
|
||||||
print '<td><a href="'.$_SERVER['PHP_SELF'].'?action=testprinter&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.$printer->listprinters[$line]['name'].'">';
|
print '<td><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 img_picto($langs->trans("TestPrinter"),'printer');
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -368,9 +368,13 @@ if ($mode == 'template' && $user->admin)
|
|||||||
'dol_print_if_customer_account_balance_positive',
|
'dol_print_if_customer_account_balance_positive',
|
||||||
);
|
);
|
||||||
|
|
||||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=config" autocomplete="off">';
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=template" autocomplete="off">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="addtemplate">';
|
if ($action!='edittemplate') {
|
||||||
|
print '<input type="hidden" name="action" value="addtemplate">';
|
||||||
|
} else {
|
||||||
|
print '<input type="hidden" name="action" value="updatetemplate">';
|
||||||
|
}
|
||||||
|
|
||||||
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
||||||
|
|
||||||
@ -378,11 +382,56 @@ if ($mode == 'template' && $user->admin)
|
|||||||
print '<table class="noborder" width="100%">'."\n";
|
print '<table class="noborder" width="100%">'."\n";
|
||||||
$var=true;
|
$var=true;
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
print '<th>'.$langs->trans("Name").'</th>';
|
||||||
print '<th>'.$langs->trans("Template").'</th>';
|
print '<th>'.$langs->trans("Template").'</th>';
|
||||||
print '<th></th>';
|
print '<th></th>';
|
||||||
|
print '<th></th>';
|
||||||
|
print '<th></th>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
$ret = $printer->listPrintersTemplates();
|
||||||
|
//print '<pre>'.print_r($printer->listprinterstemplates, true).'</pre>';
|
||||||
|
if ($ret > 0) {
|
||||||
|
setEventMessages($printer->error, $printer->errors, 'errors');
|
||||||
|
} else {
|
||||||
|
for ($line=0; $line < count($printer->listprinterstemplates); $line++) {
|
||||||
|
$var = !$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
if ($action=='edittemplate' && $printer->listprinterstemplates[$line]['rowid']==$templateid) {
|
||||||
|
print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">';
|
||||||
|
print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['name'].'"></td>';
|
||||||
|
// TODO doleditor
|
||||||
|
print '<td><input size="120" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['template'].'"></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>';
|
||||||
|
// delete icon
|
||||||
|
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=template&action=deletetemplate&templateid='.$printer->listprinterstemplates[$line]['rowid'].'&printername='.$printer->listprinters[$line]['name'].'">';
|
||||||
|
print img_picto($langs->trans("Delete"),'delete');
|
||||||
|
print '</a></td>';
|
||||||
|
// test icon
|
||||||
|
print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=template&action=testtemplate&templateid='.$printer->listprinterstemplates[$line]['rowid'].'&printername='.$printer->listprinters[$line]['name'].'">';
|
||||||
|
print img_picto($langs->trans("TestPrinterTemplate"),'printer');
|
||||||
|
print '</a></td>';
|
||||||
|
}
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
if ($action!='edittemplate') {
|
||||||
|
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
|
||||||
|
} else {
|
||||||
|
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
|
||||||
|
}
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
print '<div><p></div>';
|
||||||
print '<table class="noborder" width="100%">'."\n";
|
print '<table class="noborder" width="100%">'."\n";
|
||||||
$var=true;
|
$var=true;
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
@ -396,6 +445,7 @@ if ($mode == 'template' && $user->admin)
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,7 +122,7 @@ class dolReceiptPrinter extends Escpos
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* list printers
|
||||||
*
|
*
|
||||||
* @return int 0 if OK; >0 if KO
|
* @return int 0 if OK; >0 if KO
|
||||||
*/
|
*/
|
||||||
@ -150,6 +150,35 @@ class dolReceiptPrinter extends Escpos
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List printers templates
|
||||||
|
*
|
||||||
|
* @return int 0 if OK; >0 if KO
|
||||||
|
*/
|
||||||
|
function listPrintersTemplates()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$error = 0;
|
||||||
|
$line = 0;
|
||||||
|
$sql = 'SELECT rowid, name, template';
|
||||||
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
|
||||||
|
$sql.= ' WHERE entity = '.$conf->entity;
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
while ($line < $num) {
|
||||||
|
$obj[] = $this->db->fetch_array($resql);
|
||||||
|
$line++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
$this->errors[] = $this->db->lasterror;
|
||||||
|
}
|
||||||
|
$this->listprinterstemplates = $obj;
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form to Select type printer
|
* Form to Select type printer
|
||||||
*
|
*
|
||||||
@ -243,7 +272,7 @@ class dolReceiptPrinter extends Escpos
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to Send Test äge to Printer
|
* Function to Send Test page to Printer
|
||||||
*
|
*
|
||||||
* @param int $printerid Printer id
|
* @param int $printerid Printer id
|
||||||
* @return int 0 if OK; >0 if KO
|
* @return int 0 if OK; >0 if KO
|
||||||
@ -308,4 +337,25 @@ class dolReceiptPrinter extends Escpos
|
|||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to Print Receipt Ticket
|
||||||
|
*
|
||||||
|
* @param object $object order or invoice object
|
||||||
|
* @param int $template Template id
|
||||||
|
* @param int $printerid Printer id
|
||||||
|
* @return int 0 if OK; >0 if KO
|
||||||
|
*/
|
||||||
|
function SendToPrinter($object, $template, $printerid)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
// parse template
|
||||||
|
|
||||||
|
|
||||||
|
// print ticket
|
||||||
|
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user