Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into 3.9_NEW_multityppeeventfilter
This commit is contained in:
commit
99513ac9f3
@ -290,6 +290,12 @@ source_file = htdocs/langs/en_US/propal.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.receiptprinter]
|
||||
file_filter = htdocs/langs/<lang>/receiptprinter.lang
|
||||
source_file = htdocs/langs/en_US/receiptprinter.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.resource]
|
||||
file_filter = htdocs/langs/<lang>/resource.lang
|
||||
source_file = htdocs/langs/en_US/resource.lang
|
||||
|
||||
@ -239,7 +239,7 @@ http://packages.qa.debian.org/t/tcpdf.html
|
||||
|
||||
##### Create/Maintain dolibarr package
|
||||
|
||||
To update dolibarr debian package when upstream version has changed
|
||||
To update dolibarr debian package when upstream (official version of external project) has changed:
|
||||
|
||||
* You can git clone debian git repo
|
||||
> git clone git.debian.org:/git/collab-maint/dolibarr.git [dolibarr-debian]
|
||||
@ -284,10 +284,10 @@ Then check/modify also the user/date signature:
|
||||
- Name and email must match value into debian/control file (Entry added here is used by next step).
|
||||
|
||||
|
||||
To update dolibarr debian package when only files into debian has changed
|
||||
To update dolibarr debian package when only files into debian has changed, or if you include manually backport:
|
||||
|
||||
* Change files and commit.
|
||||
* Add a tag debian/x.y.z+dfsgw-2 (increase the last 1 into 2)
|
||||
* Add a tag debian/x.y.z+dfsgw-2 (increase the last 1 into 2, 3...)
|
||||
|
||||
|
||||
Once files has been prepared, it's time to test:
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
"ext-curl": "*",
|
||||
"ccampbell/chromephp": "^4.1",
|
||||
"ckeditor/ckeditor": "4.3.3",
|
||||
"mike42/escpos-php": "dev-master",
|
||||
"mobiledetect/mobiledetectlib": "2.8.3",
|
||||
"phpoffice/phpexcel": "1.8.0",
|
||||
"restler/framework": "^3.0",
|
||||
|
||||
66
composer.lock
generated
66
composer.lock
generated
@ -4,7 +4,8 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "f441e6348ae7862942693cab10810418",
|
||||
"hash": "d88b5c84a9ea1af354d867ba2e2ab251",
|
||||
"content-hash": "85e60ec7f8ab593387c7bd10d8db860d",
|
||||
"packages": [
|
||||
{
|
||||
"name": "ccampbell/chromephp",
|
||||
@ -126,6 +127,64 @@
|
||||
"homepage": "https://github.com/firephp/firephp-core",
|
||||
"time": "2013-04-23 15:28:20"
|
||||
},
|
||||
{
|
||||
"name": "mike42/escpos-php",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mike42/escpos-php.git",
|
||||
"reference": "0564ff94de45564221eca99c4cd5ab24492894c2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/mike42/escpos-php/zipball/0564ff94de45564221eca99c4cd5ab24492894c2",
|
||||
"reference": "0564ff94de45564221eca99c4cd5ab24492894c2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.5.*"
|
||||
},
|
||||
"type": "library",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roni Saha",
|
||||
"email": "roni.cse@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Michael Billington",
|
||||
"email": "michael.billington@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Gergely Radics",
|
||||
"email": "gerifield@ustream.tv"
|
||||
},
|
||||
{
|
||||
"name": "Warren Doyle",
|
||||
"email": "w.doyle@fuelled.co"
|
||||
},
|
||||
{
|
||||
"name": "vharo",
|
||||
"email": "vharo@geepok.com"
|
||||
}
|
||||
],
|
||||
"description": "Thermal receipt printer library, for use with ESC/POS compatible printers",
|
||||
"homepage": "https://github.com/mike42/escpos-php",
|
||||
"keywords": [
|
||||
"ESC-POS",
|
||||
"driver",
|
||||
"escpos",
|
||||
"print",
|
||||
"receipt"
|
||||
],
|
||||
"time": "2015-11-02 10:50:46"
|
||||
},
|
||||
{
|
||||
"name": "mobiledetect/mobiledetectlib",
|
||||
"version": "2.8.3",
|
||||
@ -424,13 +483,16 @@
|
||||
"pdf417",
|
||||
"qrcode"
|
||||
],
|
||||
"abandoned": "tecnickcom/tcpdf",
|
||||
"time": "2015-01-28 18:51:40"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {
|
||||
"mike42/escpos-php": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
||||
@ -19,8 +19,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file dev/intdata/generate-facture.php
|
||||
* \brief Script de generation de donnees aleatoires pour les factures
|
||||
* \file dev/intdata/generate-invoice.php
|
||||
* \brief Script example to inject random customer invoices (for load tests)
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file dev/initdata/generate-commande.php
|
||||
* \brief Script de generation de donnees aleatoires pour les commandes
|
||||
* \file dev/initdata/generate-order.php
|
||||
* \brief Script example to inject random orders (for load tests)
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file dev/initdata/generate-produit.php
|
||||
* \brief Script de generation de donnees aleatoires pour les produits
|
||||
* \file dev/initdata/generate-product.php
|
||||
* \brief Script example to inject random products (for load tests)
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file dev/initdata/generate-propale.php
|
||||
* \brief Script de generation de donnees aleatoires pour les propales
|
||||
* \file dev/initdata/generate-proposal.php
|
||||
* \brief Script example to inject random proposals (for load tests)
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file dev/initdata/generate-societe.php
|
||||
* \brief Script de generation de donnees aleatoires pour les societes
|
||||
* \file dev/initdata/generate-thirdparty.php
|
||||
* \brief Script example to inject random thirdparties (for load tests)
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
@ -15,6 +15,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* Get a distant dump file and load it into a mysql database
|
||||
*/
|
||||
|
||||
$sapi_type = php_sapi_name();
|
||||
@ -32,9 +34,10 @@ $error=0;
|
||||
|
||||
$sourceserver=isset($argv[1])?$argv[1]:''; // user@server:/src/file
|
||||
$password=isset($argv[2])?$argv[2]:'';
|
||||
$database=isset($argv[3])?$argv[3]:'';
|
||||
$loginbase=isset($argv[4])?$argv[4]:'';
|
||||
$passwordbase=isset($argv[5])?$argv[5]:'';
|
||||
$dataserver=isset($argv[3])?$argv[3]:'';
|
||||
$database=isset($argv[4])?$argv[4]:'';
|
||||
$loginbase=isset($argv[5])?$argv[5]:'';
|
||||
$passwordbase=isset($argv[6])?$argv[6]:'';
|
||||
|
||||
// Include Dolibarr environment
|
||||
$res=0;
|
||||
@ -64,7 +67,7 @@ if (preg_match('/^(.*)@(.*):(.*)$/',$sourceserver,$reg))
|
||||
}
|
||||
if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase))
|
||||
{
|
||||
print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh database loginbase passbase\n";
|
||||
print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n";
|
||||
print "Return code: 0 if success, <>0 if error\n";
|
||||
print "Warning, this script may take a long time.\n";
|
||||
exit(-1);
|
||||
@ -108,14 +111,14 @@ if ($connection)
|
||||
print 'Get file '.$sourcefile.' into '.$targetdir.$targetfile."\n";
|
||||
ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile);
|
||||
|
||||
$fullcommand="cat ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
$fullcommand="cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
if (preg_match('/\.bz2$/',$targetfile))
|
||||
{
|
||||
$fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
$fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
}
|
||||
if (preg_match('/\.gz$/',$targetfile))
|
||||
{
|
||||
$fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
$fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
}
|
||||
print "Load dump with ".$fullcommand."\n";
|
||||
$output=array();
|
||||
|
||||
@ -561,7 +561,7 @@ foreach ($skeletonfiles as $skeletonfile => $outfile)
|
||||
{
|
||||
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
|
||||
{
|
||||
$varprop.="if (\$search_".$prop['field']." != '') \$params.= '&search_".$prop['field']."='.urlencode(\$search_".$prop['field']."\n);";
|
||||
$varprop.="if (\$search_".$prop['field']." != '') \$params.= '&search_".$prop['field']."='.urlencode(\$search_".$prop['field'].");\n";
|
||||
}
|
||||
}
|
||||
$targetcontent=preg_replace('/'.preg_quote("if (\$search_field1 != '') \$params.= '&search_field1='.urlencode(\$search_field1);",'/').'/', $varprop, $targetcontent);
|
||||
@ -619,6 +619,43 @@ foreach ($skeletonfiles as $skeletonfile => $outfile)
|
||||
$targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field1']['checked'])) print '<td>'.\$obj->field1.'</td>';",'/').'/', $varprop, $targetcontent);
|
||||
$targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field2']['checked'])) print '<td>'.\$obj->field2.'</td>';",'/').'/', '', $targetcontent);
|
||||
|
||||
// LIST_OF_TD_LABEL_FIELDS_CREATE - List of td for card view
|
||||
$varprop="\n";
|
||||
$cleanparam='';
|
||||
foreach($property as $key => $prop)
|
||||
{
|
||||
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
|
||||
{
|
||||
$varprop.="print '<tr><td class=\"fieldrequired\">'.\$langs->trans(\"Field".$prop['field']."\").'</td><td><input class=\"flat\" type=\"text\" name=\"".$prop['field']."\" value=\"'.GETPOST('".$prop['field']."').'\"></td></tr>';\n";
|
||||
}
|
||||
}
|
||||
$targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_CREATE/', $varprop, $targetcontent);
|
||||
|
||||
// LIST_OF_TD_LABEL_FIELDS_EDIT - List of td for card view
|
||||
$varprop="\n";
|
||||
$cleanparam='';
|
||||
foreach($property as $key => $prop)
|
||||
{
|
||||
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
|
||||
{
|
||||
$varprop.="print '<tr><td class=\"fieldrequired\">'.\$langs->trans(\"Field".$prop['field']."\").'</td><td><input class=\"flat\" type=\"text\" name=\"".$prop['field']."\" value=\"'.\$object->".$prop['field'].".'\"></td></tr>';\n";
|
||||
}
|
||||
}
|
||||
$targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_EDIT/', $varprop, $targetcontent);
|
||||
|
||||
// LIST_OF_TD_LABEL_FIELDS_VIEW - List of td for card view
|
||||
$varprop="\n";
|
||||
$cleanparam='';
|
||||
foreach($property as $key => $prop)
|
||||
{
|
||||
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
|
||||
{
|
||||
$varprop.="print '<tr><td class=\"fieldrequired\">'.\$langs->trans(\"Field".$prop['field']."\").'</td><td>\$object->".$prop['field']."</td></tr>';\n";
|
||||
}
|
||||
}
|
||||
$targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_VIEW/', $varprop, $targetcontent);
|
||||
|
||||
|
||||
// Build file
|
||||
$fp=fopen($outfile,"w");
|
||||
if ($fp)
|
||||
|
||||
@ -230,7 +230,7 @@ jQuery(document).ready(function() {
|
||||
// Part to create
|
||||
if ($action == 'create')
|
||||
{
|
||||
print load_fiche_titre($langs->trans("NewSkeleton"));
|
||||
print load_fiche_titre($langs->trans("NewMyModule"));
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
@ -239,10 +239,8 @@ if ($action == 'create')
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border centpercent">'."\n";
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
|
||||
print '<input class="flat" type="text" size="36" name="label" value="'.$label.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>';
|
||||
// LIST_OF_TD_LABEL_FIELDS_CREATE
|
||||
print '</table>'."\n";
|
||||
|
||||
dol_fiche_end();
|
||||
@ -257,17 +255,25 @@ if ($action == 'create')
|
||||
// Part to edit record
|
||||
if (($id || $ref) && $action == 'edit')
|
||||
{
|
||||
print load_fiche_titre($langs->trans("MyModule"));
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border centpercent">'."\n";
|
||||
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>';
|
||||
// LIST_OF_TD_LABEL_FIELDS_EDIT
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div class="center"><input type="submit" class="button" name="add" value="'.$langs->trans("Create").'"></div>';
|
||||
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
@ -275,12 +281,22 @@ if (($id || $ref) && $action == 'edit')
|
||||
|
||||
|
||||
// Part to show record
|
||||
if ($id && (empty($action) || $action == 'view'))
|
||||
if ($id && (empty($action) || $action == 'view' || $action == 'delete'))
|
||||
{
|
||||
print load_fiche_titre($langs->trans("MyModule"));
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
|
||||
|
||||
if ($action == 'delete') {
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
print '<table class="border centpercent">'."\n";
|
||||
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>';
|
||||
// LIST_OF_TD_LABEL_FIELDS_VIEW
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
@ -299,14 +315,7 @@ if ($id && (empty($action) || $action == 'view'))
|
||||
|
||||
if ($user->rights->mymodule->delete)
|
||||
{
|
||||
if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile
|
||||
{
|
||||
print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
|
||||
}
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
|
||||
}
|
||||
}
|
||||
print '</div>'."\n";
|
||||
|
||||
@ -426,6 +426,101 @@ class Skeleton_Class extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a link to the user card (with optionaly the picto)
|
||||
* Use this->id,this->lastname, this->firstname
|
||||
*
|
||||
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||
* @param string $option On what the link point to
|
||||
* @param integer $notooltip 1=Disable tooltip
|
||||
* @param int $maxlen Max length of visible user name
|
||||
* @param string $morecss Add more css on link
|
||||
* @return string String with URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
|
||||
{
|
||||
global $langs, $conf, $db;
|
||||
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
||||
global $menumanager;
|
||||
|
||||
|
||||
$result = '';
|
||||
$companylink = '';
|
||||
|
||||
$label = '<u>' . $langs->trans("MyModule") . '</u>';
|
||||
$label.= '<div width="100%">';
|
||||
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/mymodule/card.php?id='.$this->id.'"';
|
||||
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
|
||||
$link.= '>';
|
||||
$linkend='</a>';
|
||||
|
||||
if ($withpicto)
|
||||
{
|
||||
$result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||
if ($withpicto != 2) $result.=' ';
|
||||
}
|
||||
$result.= $link . $this->ref . $linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le libelle du status d'un user (actif, inactif)
|
||||
*
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
function getLibStatut($mode=0)
|
||||
{
|
||||
return $this->LibStatut($this->status,$mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi le libelle d'un status donne
|
||||
*
|
||||
* @param int $status Id status
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
function LibStatut($status,$mode=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
$prefix='';
|
||||
if ($status == 1) return $langs->trans('Enabled');
|
||||
if ($status == 0) return $langs->trans('Disabled');
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Enabled');
|
||||
if ($status == 0) return $langs->trans('Disabled');
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
|
||||
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
|
||||
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
|
||||
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
||||
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise object with example values
|
||||
* Id must be 0 if object instance is a specimen
|
||||
|
||||
@ -157,7 +157,7 @@ llxHeader('','MyPageName','');
|
||||
$form=new Form($db);
|
||||
|
||||
// Put here content of your page
|
||||
print load_fiche_titre('PageTitle');
|
||||
$title = $langs->trans('MyModuleListTitle');
|
||||
|
||||
// Example : Adding jquery code
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
@ -310,7 +310,7 @@ if ($resql)
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
//if (! empty($arrayfields['u.statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"u.statut","",$param,'align="center"',$sortfield,$sortorder);
|
||||
//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
||||
@ -162,7 +162,7 @@ foreach($dirbarcode as $reldir)
|
||||
{
|
||||
$filebis=$reg[1];
|
||||
|
||||
// Chargement de la classe de codage
|
||||
// Loading encoding class
|
||||
require_once $newdir.$file;
|
||||
$classname = "mod".ucfirst($filebis);
|
||||
$module = new $classname($db);
|
||||
|
||||
@ -510,7 +510,7 @@ if ($id == 10)
|
||||
}
|
||||
|
||||
|
||||
// Actions ajout ou modification d'une entree dans un dictionnaire de donnee
|
||||
// Actions add or modify an entry into a dictionary
|
||||
if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
{
|
||||
$listfield=explode(',',$tabfield[$id]);
|
||||
@ -581,7 +581,12 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($id == 3 && ! is_numeric($_POST["code"]))
|
||||
{
|
||||
$ok=0;
|
||||
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors');
|
||||
}
|
||||
|
||||
// Clean some parameters
|
||||
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
|
||||
if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0
|
||||
|
||||
@ -344,7 +344,7 @@ foreach ($dirmodels as $reldir)
|
||||
$classname = preg_replace('/\-.*$/','',$classname);
|
||||
if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
|
||||
{
|
||||
// Chargement de la classe de numerotation
|
||||
// Charging the numbering class
|
||||
require_once $dir.$filebis;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
@ -27,6 +27,13 @@ require '../main.inc.php';
|
||||
// required Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("oauth");
|
||||
|
||||
@ -36,6 +43,8 @@ if (!$user->admin)
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
// Supported OAUTH
|
||||
$supportedoauth2array=array('OAUTH_GOOGLE_NAME');
|
||||
// API access parameters OAUTH
|
||||
$list = array (
|
||||
array(
|
||||
@ -297,11 +306,7 @@ print '<input type="hidden" name="action" value="update">';
|
||||
dol_fiche_head(array(), '', '', 0, 'technic');
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
print $langs->trans("ListOfSupportedOauthProviders").'<br><br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -309,12 +314,16 @@ $var = true;
|
||||
|
||||
foreach ($list as $key)
|
||||
{
|
||||
$supported=0;
|
||||
if (in_array($key[0], $supportedoauth2array)) $supported=1;
|
||||
if (! $supported) continue; // show only supported
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
// Api Name
|
||||
$label = $langs->trans($key[0]);
|
||||
print '<td colspan="2">'.$label.'</td></tr>';
|
||||
|
||||
if (in_array($key[0], array('OAUTH_GOOGLE_NAME')))
|
||||
if ($supported)
|
||||
{
|
||||
$redirect_uri=$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php';
|
||||
$var = !$var;
|
||||
|
||||
@ -130,7 +130,7 @@ foreach ($dirmodels as $reldir)
|
||||
$classname = preg_replace('/\-.*$/','',$classname);
|
||||
if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
|
||||
{
|
||||
// Chargement de la classe de numerotation
|
||||
// Charging the numbering class
|
||||
require_once $dir.$filebis;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
@ -62,7 +62,8 @@ if ($action == 'update')
|
||||
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity);
|
||||
|
||||
dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'',$conf->entity);
|
||||
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
|
||||
exit;
|
||||
}
|
||||
@ -247,6 +248,12 @@ if ($action == 'edit') // Edit
|
||||
print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0,1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Place customer adress to the ISO location
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>';
|
||||
print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION',(! empty($conf->global->MAIN_PDF_USE_ISO_LOCATION))?$conf->global->MAIN_PDF_USE_ISO_LOCATION:0,1);
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -444,6 +451,10 @@ else // Show
|
||||
print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1);
|
||||
print '</td></tr>';
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td colspan="2">';
|
||||
print yn($conf->global->MAIN_PDF_USE_ISO_LOCATION,1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
@ -425,7 +425,7 @@ if ($mode == 'template' && $user->admin)
|
||||
}
|
||||
|
||||
// to remove after test
|
||||
$object->date = '2015-11-02 22:30:25';
|
||||
$object->date_time = '2015-11-02 22:30:25';
|
||||
$object->id = 1234;
|
||||
$object->customer_firstname = 'John';
|
||||
$object->customer_lastname = 'Deuf';
|
||||
|
||||
@ -221,7 +221,7 @@ if (is_resource($handle))
|
||||
{
|
||||
if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i',$file,$reg))
|
||||
{
|
||||
// Chargement de la classe de numerotation
|
||||
// Charging the numbering class
|
||||
$classname = $reg[1];
|
||||
require_once $dir.'/'.$file;
|
||||
|
||||
|
||||
@ -175,7 +175,7 @@ if (! empty($conf->receiptprinter->enabled))
|
||||
{
|
||||
$var=! $var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print $langs->trans("DolibarrReceiptPrinter");
|
||||
print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')';
|
||||
print '<td colspan="2">';
|
||||
print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER",$conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER,1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
@ -101,12 +101,12 @@ if ($action == 'update' && $user->rights->categorie->creer)
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($categorie->error, 'errors');
|
||||
setEventMessages($categorie->error, $categorie->errors, 'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($categorie->error, 'errors');
|
||||
setEventMessages($categorie->error, $categorie->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ $cancel != $langs->trans("Cancel") &&
|
||||
else
|
||||
{
|
||||
$action = 'add';
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ $cancel != $langs->trans("Cancel") &&
|
||||
else
|
||||
{
|
||||
$action = 'edit';
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,13 +137,13 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory'
|
||||
$result=$object->add_type($newobject,$elementtype);
|
||||
if ($result >= 0)
|
||||
{
|
||||
setEventMessage($langs->trans("WasAddedSuccessfully",$newobject->ref));
|
||||
setEventMessages($langs->trans("WasAddedSuccessfully",$newobject->ref), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings');
|
||||
setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -96,7 +96,7 @@ $hookmanager->initHooks(array('actioncard','globalcard'));
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$listUserAssignedUpdated = false;
|
||||
// Remove user to assigned list
|
||||
if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
|
||||
{
|
||||
@ -114,6 +114,8 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
|
||||
$donotclearsession=1;
|
||||
if ($action == 'add') $action = 'create';
|
||||
if ($action == 'update') $action = 'edit';
|
||||
|
||||
$listUserAssignedUpdated = true;
|
||||
}
|
||||
|
||||
// Add user to assigned list
|
||||
@ -133,6 +135,8 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
|
||||
$donotclearsession=1;
|
||||
if ($action == 'add') $action = 'create';
|
||||
if ($action == 'update') $action = 'edit';
|
||||
|
||||
$listUserAssignedUpdated = true;
|
||||
}
|
||||
|
||||
// Action clone object
|
||||
@ -838,6 +842,28 @@ if ($id > 0)
|
||||
$result4=$object->fetch_userassigned();
|
||||
$result5=$object->fetch_optionals($id,$extralabels);
|
||||
|
||||
if($listUserAssignedUpdated || $donotclearsession) {
|
||||
|
||||
$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
|
||||
$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
|
||||
|
||||
$object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm');
|
||||
$object->label = GETPOST("label");
|
||||
$object->datep = $datep;
|
||||
$object->datef = $datef;
|
||||
$object->percentage = $percentage;
|
||||
$object->priority = GETPOST("priority");
|
||||
$object->fulldayevent= GETPOST("fullday")?1:0;
|
||||
$object->location = GETPOST('location');
|
||||
$object->socid = GETPOST("socid");
|
||||
$object->contactid = GETPOST("contactid",'int');
|
||||
//$object->societe->id = $_POST["socid"]; // deprecated
|
||||
//$object->contact->id = $_POST["contactid"]; // deprecated
|
||||
$object->fk_project = GETPOST("projectid",'int');
|
||||
|
||||
$object->note = GETPOST("note");
|
||||
}
|
||||
|
||||
if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
|
||||
{
|
||||
dol_print_error($db,$object->error);
|
||||
|
||||
@ -62,7 +62,7 @@ if ($action == 'builddoc')
|
||||
$result=$cat->write_file(GETPOST('id','int'));
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessage($cat->error, 'errors');
|
||||
setEventMessages($cat->error, $cat->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ if ($action == 'add' || $action == 'update')
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='create';
|
||||
}
|
||||
}
|
||||
@ -147,7 +147,7 @@ if ($action == 'add' || $action == 'update')
|
||||
else
|
||||
{
|
||||
$reload = 0;
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action= "edit";
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ if (empty($reshook))
|
||||
$result=$object->fetch($id);
|
||||
$object->code_compta=$_POST["customeraccountancycode"];
|
||||
$result=$object->update($object->id,$user,1,1,0);
|
||||
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// conditions de reglement
|
||||
@ -113,7 +113,7 @@ if (empty($reshook))
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
|
||||
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// mode de reglement
|
||||
@ -121,7 +121,7 @@ if (empty($reshook))
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
|
||||
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// assujetissement a la TVA
|
||||
@ -130,7 +130,7 @@ if (empty($reshook))
|
||||
$object->fetch($id);
|
||||
$object->tva_assuj=$_POST['assujtva_value'];
|
||||
$result=$object->update($object->id);
|
||||
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// set prospect level
|
||||
@ -157,7 +157,7 @@ if (empty($reshook))
|
||||
$object->fetch($id);
|
||||
$object->outstanding_limit=GETPOST('outstanding_limit');
|
||||
$result=$object->set_OutstandingBill($user);
|
||||
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ if (empty($reshook))
|
||||
{
|
||||
if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
|
||||
{
|
||||
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
|
||||
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -129,7 +129,7 @@ if (empty($reshook))
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$action='';
|
||||
@ -141,14 +141,14 @@ if (empty($reshook))
|
||||
if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
|
||||
{
|
||||
// As security measure, we don't allow send from the GUI
|
||||
setEventMessage($langs->trans("MailingNeedCommand"), 'warnings');
|
||||
setEventMessage('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', 'warnings');
|
||||
setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings');
|
||||
setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
|
||||
setEventMessages('<textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings');
|
||||
setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings');
|
||||
$action='';
|
||||
}
|
||||
else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
|
||||
{
|
||||
setEventMessage($langs->trans("NotEnoughPermissions"), 'warnings');
|
||||
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings');
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
@ -351,27 +351,27 @@ if (empty($reshook))
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"));
|
||||
setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs');
|
||||
}
|
||||
|
||||
// Loop finished, set global statut of mail
|
||||
if ($nbko > 0)
|
||||
{
|
||||
$statut=2; // Status 'sent partially' (because at least one error)
|
||||
if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok));
|
||||
else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok));
|
||||
if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
|
||||
else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($nbok >= $num)
|
||||
{
|
||||
$statut=3; // Send to everybody
|
||||
setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok));
|
||||
setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$statut=2; // Status 'sent partially' (because not send to everybody)
|
||||
setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok));
|
||||
setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,11 +443,11 @@ if (empty($reshook))
|
||||
$result=$mailfile->sendfile();
|
||||
if ($result)
|
||||
{
|
||||
setEventMessage($langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)));
|
||||
setEventMessages($langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result, 'errors');
|
||||
setEventMessages($langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result, null, 'errors');
|
||||
}
|
||||
|
||||
$action='';
|
||||
@ -488,7 +488,7 @@ if (empty($reshook))
|
||||
$mesgs[] = $object->error;
|
||||
}
|
||||
|
||||
setEventMessage($mesgs, 'errors');
|
||||
setEventMessages($mesg, $mesgs, 'errors');
|
||||
$action="create";
|
||||
}
|
||||
|
||||
@ -518,7 +518,7 @@ if (empty($reshook))
|
||||
$mesg = $object->error;
|
||||
}
|
||||
|
||||
setEventMessage($mesg, 'errors');
|
||||
setEventMessages($mesg, $mesgs, 'errors');
|
||||
$action="";
|
||||
}
|
||||
|
||||
@ -582,7 +582,7 @@ if (empty($reshook))
|
||||
$mesgs[] =$object->error;
|
||||
}
|
||||
|
||||
setEventMessage($mesgs, 'errors');
|
||||
setEventMessages($mesg, $mesgs, 'errors');
|
||||
$action="edit";
|
||||
}
|
||||
else
|
||||
@ -597,7 +597,7 @@ if (empty($reshook))
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$object->valid($user);
|
||||
setEventMessage($langs->trans("MailingSuccessfullyValidated"));
|
||||
setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
@ -628,7 +628,7 @@ if (empty($reshook))
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
@ -764,18 +764,18 @@ else
|
||||
// You ensure that every user is using its own SMTP server.
|
||||
$linktoadminemailbefore='<a href="'.DOL_URL_ROOT.'/admin/mails.php">';
|
||||
$linktoadminemailend='</a>';
|
||||
setEventMessage($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), 'warnings');
|
||||
setEventMessage($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), 'warnings');
|
||||
if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessage($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), 'warnings');
|
||||
setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings');
|
||||
setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings');
|
||||
if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings');
|
||||
$_GET["action"]='';
|
||||
}
|
||||
else if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
|
||||
{
|
||||
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
|
||||
// on affiche donc juste un message
|
||||
setEventMessage($langs->trans("MailingNeedCommand"), 'warnings');
|
||||
setEventMessage('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', 'warnings');
|
||||
setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings');
|
||||
setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
|
||||
setEventMessages('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', null, 'warnings');
|
||||
setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings');
|
||||
$_GET["action"]='';
|
||||
}
|
||||
else
|
||||
|
||||
@ -80,7 +80,7 @@ if ($action == 'add')
|
||||
//print $dir."\n<br>";
|
||||
dol_syslog("Scan directory ".$dir." for modules");
|
||||
|
||||
// Chargement de la classe
|
||||
// Loading Class
|
||||
$file = $dir."/".$module.".modules.php";
|
||||
$classname = "mailing_".$module;
|
||||
|
||||
@ -100,24 +100,24 @@ if ($action == 'add')
|
||||
}
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessage($langs->trans("XTargetsAdded",$result),'mesgs');
|
||||
setEventMessages($langs->trans("XTargetsAdded",$result), null, 'mesgs');
|
||||
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
if ($result == 0)
|
||||
{
|
||||
setEventMessage($langs->trans("WarningNoEMailsAdded"),'warnings');
|
||||
setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings');
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessage($langs->trans("Error").($obj->error?' '.$obj->error:''),'errors');
|
||||
setEventMessages($langs->trans("Error").($obj->error?' '.$obj->error:''), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOST('clearlist'))
|
||||
{
|
||||
// Chargement de la classe
|
||||
// Loading Class
|
||||
$obj = new MailingTargets($db);
|
||||
$obj->clear_target($id);
|
||||
|
||||
@ -267,7 +267,7 @@ if ($object->fetch($id) >= 0)
|
||||
// Loop on each submodule
|
||||
foreach($modulenames as $modulename)
|
||||
{
|
||||
// Chargement de la classe
|
||||
// Loading Class
|
||||
$file = $dir.$modulename.".modules.php";
|
||||
$classname = "mailing_".$modulename;
|
||||
require_once $file;
|
||||
|
||||
@ -83,7 +83,7 @@ if (is_resource($handle))
|
||||
$modulename=$reg[1];
|
||||
if ($modulename == 'example') continue;
|
||||
|
||||
// Chargement de la classe
|
||||
// Loading Class
|
||||
$file = $dir."/".$modulename.".modules.php";
|
||||
$classname = "mailing_".$modulename;
|
||||
require_once $file;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2010-2015 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
@ -131,7 +131,7 @@ if (empty($reshook))
|
||||
{
|
||||
if (! GETPOST('socid', 3))
|
||||
{
|
||||
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
|
||||
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -141,7 +141,7 @@ if (empty($reshook))
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
|
||||
exit();
|
||||
} else {
|
||||
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
|
||||
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
@ -157,7 +157,7 @@ if (empty($reshook))
|
||||
exit();
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
setEventMessage($langs->trans($object->error), 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,8 +211,8 @@ if (empty($reshook))
|
||||
}
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
|
||||
else setEventMessage($langs->trans($object->error), 'errors');
|
||||
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
else setEventMessages($langs->trans($object->error), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ if (empty($reshook))
|
||||
|
||||
$id = $object->create_from($user);
|
||||
} else {
|
||||
setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors');
|
||||
setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors');
|
||||
}
|
||||
} else {
|
||||
$object->ref = GETPOST('ref');
|
||||
@ -507,7 +507,7 @@ if (empty($reshook))
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
|
||||
setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -671,7 +671,7 @@ if (empty($reshook))
|
||||
if ($object->id > 0) {
|
||||
$result = $object->insert_discount($_POST["remise_id"]);
|
||||
if ($result < 0) {
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -875,7 +875,7 @@ if (empty($reshook))
|
||||
|
||||
if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) {
|
||||
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
|
||||
setEventMessage($mesg, 'errors');
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
} else {
|
||||
// Insert line
|
||||
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit);
|
||||
@ -929,13 +929,13 @@ if (empty($reshook))
|
||||
} else {
|
||||
$db->rollback();
|
||||
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mise a jour d'une ligne dans la propale
|
||||
// Update a line within proposal
|
||||
else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save'))
|
||||
{
|
||||
// Define info_bits
|
||||
@ -991,7 +991,7 @@ if (empty($reshook))
|
||||
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
|
||||
|
||||
if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
|
||||
setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors');
|
||||
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
|
||||
$error ++;
|
||||
}
|
||||
} else {
|
||||
@ -1040,7 +1040,7 @@ if (empty($reshook))
|
||||
} else {
|
||||
$db->rollback();
|
||||
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1137,9 +1137,9 @@ if (empty($reshook))
|
||||
} else {
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
} else {
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1636,13 +1636,13 @@ if ($action == 'create')
|
||||
else if ($action == 'validate') {
|
||||
$error = 0;
|
||||
|
||||
// on verifie si l'objet est en numerotation provisoire
|
||||
// We verifie whether the object is provisionally numbering
|
||||
$ref = substr($object->ref, 1, 4);
|
||||
if ($ref == 'PROV') {
|
||||
$numref = $object->getNextNumRef($soc);
|
||||
if (empty($numref)) {
|
||||
$error ++;
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} else {
|
||||
$numref = $object->ref;
|
||||
|
||||
@ -375,13 +375,15 @@ class Propal extends CommonObject
|
||||
* @param int $date_end End date of the line
|
||||
* @param array $array_options extrafields array
|
||||
* @param string $fk_unit Code of the unit to use. Null to use the default one
|
||||
* @param string $origin 'order', ...
|
||||
* @param int $origin_id Id of origin object
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*
|
||||
* @see add_product
|
||||
*/
|
||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null)
|
||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
|
||||
{
|
||||
global $mysoc;
|
||||
global $mysoc, $conf, $langs;
|
||||
|
||||
dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
@ -499,6 +501,9 @@ class Propal extends CommonObject
|
||||
$this->line->fk_fournprice = $fk_fournprice;
|
||||
$this->line->pa_ht = $pa_ht;
|
||||
|
||||
$this->line->origin_id = $origin_id;
|
||||
$this->line->origin = $origin;
|
||||
|
||||
// Mise en option de la ligne
|
||||
if (empty($qty) && empty($special_code)) $this->line->special_code=3;
|
||||
|
||||
@ -570,7 +575,8 @@ class Propal extends CommonObject
|
||||
{
|
||||
global $mysoc;
|
||||
|
||||
dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$a_ht, type=$type, date_start=$date_start, date_end=$date_end");
|
||||
dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent,
|
||||
txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end");
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
// Clean parameters
|
||||
@ -894,7 +900,9 @@ class Propal extends CommonObject
|
||||
$this->lines[$i]->date_start,
|
||||
$this->lines[$i]->date_end,
|
||||
$this->lines[$i]->array_options,
|
||||
$this->lines[$i]->fk_unit
|
||||
$this->lines[$i]->fk_unit,
|
||||
$this->element,
|
||||
$this->lines[$i]->id
|
||||
);
|
||||
|
||||
if ($result < 0)
|
||||
@ -1384,7 +1392,10 @@ class Propal extends CommonObject
|
||||
*/
|
||||
function update_extrafields($user)
|
||||
{
|
||||
global $conf, $hookmanager;
|
||||
|
||||
$action='update';
|
||||
$error = 0;
|
||||
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// TODO le hook fait double emploi avec le trigger !!
|
||||
@ -2717,7 +2728,7 @@ class Propal extends CommonObject
|
||||
*/
|
||||
function getNomUrl($withpicto=0,$option='', $get_params='')
|
||||
{
|
||||
global $langs;
|
||||
global $langs, $conf;
|
||||
|
||||
$result='';
|
||||
$label = '<u>' . $langs->trans("ShowPropal") . '</u>';
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
|
||||
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -54,12 +54,12 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($ret == 0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
|
||||
setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
else if ($ret < 0)
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ else
|
||||
|
||||
|
||||
/*
|
||||
* Ajout d'un nouveau contact
|
||||
* Add a new contact
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->rights->propale->creer)
|
||||
@ -96,16 +96,16 @@ if ($action == 'addcontact' && $user->rights->propale->creer)
|
||||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
|
||||
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($object->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bascule du statut d'un contact
|
||||
// Toggle the status of a contact
|
||||
else if ($action == 'swapstatut' && $user->rights->propale->creer)
|
||||
{
|
||||
if ($object->id > 0)
|
||||
@ -114,7 +114,7 @@ else if ($action == 'swapstatut' && $user->rights->propale->creer)
|
||||
}
|
||||
}
|
||||
|
||||
// Efface un contact
|
||||
// Deletes a contact
|
||||
else if ($action == 'deletecontact' && $user->rights->propale->creer)
|
||||
{
|
||||
$result = $object->delete_contact($lineid);
|
||||
|
||||
@ -65,17 +65,17 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
|
||||
if (! $res > 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessage($langs->trans("ErrorFailedToLoadDiscount"), 'errors');
|
||||
setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors');
|
||||
}
|
||||
if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc)
|
||||
{
|
||||
$error++;
|
||||
setEventMessage($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), 'errors');
|
||||
setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors');
|
||||
}
|
||||
if (! $error && $discount->fk_facture_line)
|
||||
{
|
||||
$error++;
|
||||
setEventMessage($langs->trans("ErrorCantSplitAUsedDiscount"), 'errors');
|
||||
setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors');
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
@ -166,13 +166,13 @@ if ($action == 'setremise')
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
setEventMessage($soc->error, 'errors');
|
||||
setEventMessages($soc->error, $soc->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), 'errors');
|
||||
setEventMessages($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm")=='yes')
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($discount->error, 'errors');
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
@ -216,7 +216,7 @@ if ($socid > 0)
|
||||
$object->fetch($socid);
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
* Display tabs
|
||||
*/
|
||||
$head = societe_prepare_head($object);
|
||||
|
||||
@ -300,7 +300,7 @@ if ($socid > 0)
|
||||
}
|
||||
|
||||
/*
|
||||
* Liste remises fixes restant en cours (= liees a acune facture ni ligne de facture)
|
||||
* Liste remises fixes restant en cours (= liees a aucune facture ni ligne de facture)
|
||||
*/
|
||||
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
|
||||
$sql.= " rc.datec as dc, rc.description,";
|
||||
|
||||
@ -417,7 +417,7 @@ class Commande extends CommonOrder
|
||||
{
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increment stock of product (and sub-products)
|
||||
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
|
||||
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
}
|
||||
@ -601,7 +601,7 @@ class Commande extends CommonOrder
|
||||
{
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increment stock of product (and sub-products)
|
||||
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderCanceledInDolibarr",$this->ref));
|
||||
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr",$this->ref)); // price is 0, we don't want WAP to be changed
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
@ -777,7 +777,9 @@ class Commande extends CommonOrder
|
||||
$this->lines[$i]->pa_ht,
|
||||
$this->lines[$i]->label,
|
||||
$this->lines[$i]->array_options,
|
||||
$this->lines[$i]->fk_unit
|
||||
$this->lines[$i]->fk_unit,
|
||||
$this->element,
|
||||
$this->lines[$i]->id
|
||||
);
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -950,6 +952,7 @@ class Commande extends CommonOrder
|
||||
// Clear fields
|
||||
$this->user_author_id = $user->id;
|
||||
$this->user_valid = '';
|
||||
$this->date = dol_now();
|
||||
$this->date_creation = '';
|
||||
$this->date_validation = '';
|
||||
$this->ref_client = '';
|
||||
@ -2321,6 +2324,7 @@ class Commande extends CommonOrder
|
||||
function classifyBilled()
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -2635,6 +2639,7 @@ class Commande extends CommonOrder
|
||||
global $hookmanager, $conf;
|
||||
|
||||
$action='create';
|
||||
$error = 0;
|
||||
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// TODO le hook fait double emploi avec le trigger !!
|
||||
@ -2871,7 +2876,7 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
function LibStatut($statut,$billed,$mode)
|
||||
{
|
||||
global $langs;
|
||||
global $langs, $conf;
|
||||
//print 'x'.$statut.'-'.$billed;
|
||||
if ($mode == 0)
|
||||
{
|
||||
|
||||
@ -378,19 +378,6 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($object->type != 2 && $object->rappro)
|
||||
{
|
||||
// If not cash account and can be reconciliate
|
||||
if ($user->rights->banque->consolidate)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.($vline?'&vline='.$vline:'').'">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($action != 'addline')
|
||||
{
|
||||
if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT))
|
||||
@ -409,6 +396,20 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("FeatureDisabled").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($object->type != 2 && $object->rappro)
|
||||
{
|
||||
// If not cash account and can be reconciliate
|
||||
if ($user->rights->banque->consolidate)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.($vline?'&vline='.$vline:'').'">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
@ -998,7 +998,12 @@ class Account extends CommonObject
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$this->id.$linkclose;
|
||||
$linkend='</a>';
|
||||
}
|
||||
|
||||
else if ($mode == 'receipts')
|
||||
{
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$this->id.$linkclose;
|
||||
$linkend='</a>';
|
||||
}
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($label, 'account', 'class="classfortooltip"').$linkend.' ');
|
||||
$result.=$link.$this->label.$linkend;
|
||||
return $result;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
@ -587,7 +587,7 @@ if ($result)
|
||||
if ($user->rights->banque->consolidate)
|
||||
{
|
||||
print '<td colspan="3">';
|
||||
print '<input type="checkbox" name="reconciled" class="flat" '.(isset($_POST["reconciled"])?($_POST["reconciled"]?' checked':''):($objp->rappro?' checked':'')).'">';
|
||||
print '<input type="checkbox" name="reconciled" class="flat" '.(isset($_POST["reconciled"])?($_POST["reconciled"]?' checked="checked"':''):($objp->rappro?' checked="checked"':'')).'">';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
|
||||
@ -186,7 +186,7 @@ if ($resql)
|
||||
print '<br>';
|
||||
|
||||
// Show last bank receipts
|
||||
$nbmax=5;
|
||||
$nbmax=15; // We accept to show last 15 receipts (so we can have more than one year)
|
||||
$liste="";
|
||||
$sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " WHERE fk_account=".$acct->id." AND num_releve IS NOT NULL";
|
||||
@ -226,7 +226,7 @@ if ($resql)
|
||||
print '<input type="hidden" name="account" value="'.$acct->id.'">';
|
||||
|
||||
print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
|
||||
print '<input class="flat" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):$last_releve).'" size="10">';
|
||||
print '<input class="flat" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):'').'" size="10">'; // The only default value is value we just entered
|
||||
print '<br>';
|
||||
if ($options)
|
||||
{
|
||||
|
||||
@ -157,6 +157,7 @@ if (empty($num))
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
print '<br><br>';
|
||||
|
||||
|
||||
print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows);
|
||||
@ -282,10 +283,15 @@ else
|
||||
$found=true;
|
||||
}
|
||||
|
||||
$mesprevnext ="<a href=\"releve.php?rel=prev&num=$num&ve=$ve&account=$object->id\">".img_previous()."</a> ";
|
||||
$mesprevnext.= $langs->trans("AccountStatement")." $num";
|
||||
$mesprevnext.=" <a href=\"releve.php?rel=next&num=$num&ve=$ve&account=$object->id\">".img_next()."</a>";
|
||||
print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0),$mesprevnext, 'title_bank.png');
|
||||
$mesprevnext='';
|
||||
$mesprevnext.='<div class="pagination"><ul>';
|
||||
$mesprevnext.='<li class="pagination"><a data-role="button" data-icon="arrow-l" data-iconpos="left" href="'.$_SERVER["PHP_SELF"].'?rel=prev&num='.$num.'&ve='.$ve.'&account='.$object->id.'"><</a></li>';
|
||||
//$mesprevnext.=' ';
|
||||
$mesprevnext.='<li class="pagination"><span class="inactive">'.$langs->trans("AccountStatement")." ".$num.'</span></li>';
|
||||
//$mesprevnext.=' ';
|
||||
$mesprevnext.='<li class="pagination"><a data-role="button" data-icon="arrow-r" data-iconpos="right" href="'.$_SERVER["PHP_SELF"].'?rel=next&num='.$num.'&ve='.$ve.'&account='.$object->id.'">></a></li>';
|
||||
$mesprevnext.='</ul></div>';
|
||||
print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts'), $mesprevnext, 'title_bank.png');
|
||||
print '<br>';
|
||||
|
||||
print "<form method=\"post\" action=\"releve.php\">";
|
||||
|
||||
@ -63,6 +63,7 @@ class Facture extends CommonInvoice
|
||||
var $author;
|
||||
var $fk_user_author;
|
||||
var $fk_user_valid;
|
||||
var $date; // Date invoice
|
||||
var $date_creation; // Creation date
|
||||
var $date_validation; // Validation date
|
||||
var $datem;
|
||||
@ -385,6 +386,8 @@ class Facture extends CommonInvoice
|
||||
{
|
||||
$newinvoiceline=$this->lines[$i];
|
||||
$newinvoiceline->fk_facture=$this->id;
|
||||
$newinvoiceline->origin = $this->element;
|
||||
$newinvoiceline->origin_id = $this->lines[$i]->id;
|
||||
if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0
|
||||
{
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
@ -441,8 +444,8 @@ class Facture extends CommonInvoice
|
||||
$this->lines[$i]->product_type,
|
||||
$this->lines[$i]->rang,
|
||||
$this->lines[$i]->special_code,
|
||||
'',
|
||||
0,
|
||||
$this->element,
|
||||
$this->lines[$i]->id,
|
||||
$fk_parent_line,
|
||||
$this->lines[$i]->fk_fournprice,
|
||||
$this->lines[$i]->pa_ht,
|
||||
@ -873,7 +876,7 @@ class Facture extends CommonInvoice
|
||||
*/
|
||||
function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='')
|
||||
{
|
||||
global $langs;
|
||||
global $langs, $conf;
|
||||
|
||||
$result='';
|
||||
|
||||
@ -1853,7 +1856,7 @@ class Facture extends CommonInvoice
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
$mouvP->origin = &$this;
|
||||
// We decrease stock for product
|
||||
if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num));
|
||||
if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num));
|
||||
else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num));
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
|
||||
@ -415,7 +415,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
|
||||
$datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||
$datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment);
|
||||
$form->select_date($datepayment,'','','',0,"add_paiement",1,1);
|
||||
$form->select_date($datepayment,'','','',0,"add_paiement",1,1,0,0,'','',$facture->date);
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans('Comments').'</td></tr>';
|
||||
|
||||
|
||||
@ -190,7 +190,7 @@ if ($resql)
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
// If the user can view categories of products
|
||||
if ($conf->categorie->enabled && $user->rights->produit->lire)
|
||||
if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/includes/escpos/Escpos.php';
|
||||
require_once DOL_DOCUMENT_ROOT .'/includes/mike42/escpos-php/Escpos.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -429,6 +429,7 @@ class dolReceiptPrinter extends Escpos
|
||||
$this->template = str_replace('<dol_print_customer_account_balance>', $object->customer_account_balance, $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_date_time>', $object->date_time, $this->template);
|
||||
|
||||
// parse template
|
||||
$p = xml_parser_create();
|
||||
@ -438,6 +439,7 @@ class dolReceiptPrinter extends Escpos
|
||||
//print '<pre>'.print_r($vals, true).'</pre>';
|
||||
// print ticket
|
||||
$level = 0;
|
||||
$html = '<table border="1" style="width:210px"><pre>';
|
||||
$ret = $this->InitPrinter($printerid);
|
||||
if ($ret>0) {
|
||||
setEventMessages($this->error, $this->errors, 'errors');
|
||||
@ -446,33 +448,37 @@ class dolReceiptPrinter extends Escpos
|
||||
switch ($vals[$line]['tag']) {
|
||||
case 'DOL_ALIGN_CENTER':
|
||||
$this->printer->setJustification(Escpos::JUSTIFY_CENTER);
|
||||
$html.='<center>';
|
||||
$this->printer->text($vals[$line]['value']);
|
||||
break;
|
||||
case 'DOL_ALIGN_RIGHT':
|
||||
$this->printer->setJustification(Escpos::JUSTIFY_RIGHT);
|
||||
$html.='<right>';
|
||||
break;
|
||||
case 'DOL_ALIGN_LEFT':
|
||||
$this->printer->setJustification(Escpos::JUSTIFY_LEFT);
|
||||
$html.='<left>';
|
||||
break;
|
||||
case 'DOL_OPEN_DRAWER':
|
||||
$this->printer->pulse();
|
||||
$html.= ' ϟ'.nl2br($vals[$line]['value']);
|
||||
break;
|
||||
case 'DOL_PRINT_BARCODE':
|
||||
// $vals[$line]['value'] -> barcode($content, $type)
|
||||
$this->printer->barcode($object->barcode);
|
||||
break;
|
||||
case 'DOL_PRINT_DATE_TIME':
|
||||
$this->printer->text($object->date);
|
||||
break;
|
||||
case 'DOL_PRINT_QRCODE':
|
||||
// $vals[$line]['value'] -> qrCode($content, $ec, $size, $model)
|
||||
$this->printer->qrcode($vals[$line]['value']);
|
||||
$html.='QRCODE: '.$vals[$line]['value'];
|
||||
break;
|
||||
case 'DOL_CUT_PAPER_FULL':
|
||||
$this->printer->cut(Escpos::CUT_FULL);
|
||||
$html.= ' ✂'.nl2br($vals[$line]['value']);
|
||||
break;
|
||||
case 'DOL_CUT_PAPER_PARTIAL':
|
||||
$this->printer->cut(Escpos::CUT_PARTIAL);
|
||||
$html.= ' ✂'.nl2br($vals[$line]['value']);
|
||||
break;
|
||||
case 'DOL_USE_FONT_A':
|
||||
$this->printer->setFont(Escpos::FONT_A);
|
||||
@ -488,11 +494,14 @@ class dolReceiptPrinter extends Escpos
|
||||
break;
|
||||
default:
|
||||
$this->printer->text($vals[$line]['value']);
|
||||
$html.= nl2br($vals[$line]['value']);
|
||||
$this->errors[] = 'UnknowTag: <'.strtolower($vals[$line]['tag']).'>';
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$html.= '</pre></table>';
|
||||
print $html;
|
||||
// Close and print
|
||||
// uncomment next line to see content sent to printer
|
||||
//print '<pre>'.print_r($this->connector, true).'</pre>';
|
||||
|
||||
@ -258,7 +258,7 @@ class ExtraFields
|
||||
|
||||
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
|
||||
{
|
||||
if(is_array($param) and count($param) > 0)
|
||||
if(is_array($param) && count($param) > 0)
|
||||
{
|
||||
$params = $this->db->escape(serialize($param));
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ class HookManager
|
||||
* @param Object $object Object to use hooks on
|
||||
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
|
||||
* @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
||||
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
||||
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
||||
* All types can also return some values into an array ->results.
|
||||
* $this->error or this->errors are also defined by class called by this function if error.
|
||||
*/
|
||||
|
||||
@ -1546,7 +1546,7 @@ class Form
|
||||
print img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
}
|
||||
print '<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' autofocus />';
|
||||
print '<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
|
||||
if ($hidelabel == 3) {
|
||||
print img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
@ -1663,7 +1663,7 @@ class Form
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
$out.='<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'" autofocus>';
|
||||
$out.='<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||
$out.='<option value="0" selected> </option>';
|
||||
|
||||
$i = 0;
|
||||
@ -4057,10 +4057,11 @@ class Form
|
||||
* @param int $disabled Disable input fields
|
||||
* @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59
|
||||
* @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field.
|
||||
* @param datetime $adddateof Add a link "Date of invoice" using the following date.
|
||||
* @return mixed Nothing or string if nooutput is 1
|
||||
* @see form_date
|
||||
*/
|
||||
function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='')
|
||||
function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='')
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@ -4318,6 +4319,13 @@ class Form
|
||||
}
|
||||
}
|
||||
|
||||
// Add a "Plus one hour" link
|
||||
if ($conf->use_javascript_ajax && $adddateof)
|
||||
{
|
||||
$tmparray=dol_getdate($adddateof);
|
||||
$retstring.=' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\''.dol_print_date($adddateof,'day').'\');jQuery(\'#reday\').val(\''.$tmparray['mday'].'\');jQuery(\'#remonth\').val(\''.$tmparray['mon'].'\');jQuery(\'#reyear\').val(\''.$tmparray['year'].'\');">'.$langs->trans("DateInvoice").'</a>';
|
||||
}
|
||||
|
||||
if (! empty($nooutput)) return $retstring;
|
||||
|
||||
print $retstring;
|
||||
@ -4513,22 +4521,26 @@ class Form
|
||||
* @param string $morecss Add more class to css styles
|
||||
* @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected.
|
||||
* @param string $placeholder String to use as placeholder
|
||||
* @return string HTML select string.
|
||||
* @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
|
||||
* @return string HTML select string
|
||||
*/
|
||||
static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='')
|
||||
static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0)
|
||||
{
|
||||
global $langs;
|
||||
global $delayedhtmlcontent;
|
||||
|
||||
$out = '';
|
||||
|
||||
$tmpplugin='select2';
|
||||
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
|
||||
|
||||
$out='<input type="text" class="'.$htmlname.($morecss?' '.$morecss:'').'" '.($moreparam?$moreparam.' ':'').'name="'.$htmlname.'">';
|
||||
|
||||
// TODO Use an internal dolibarr component instead of select2
|
||||
$outdelayed='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
|
||||
'.($callurlonselect ? 'var saveRemoteData = [];':'').'
|
||||
'.($callurlonselect ? 'var saveRemoteData = [];':'').'
|
||||
|
||||
$(".'.$htmlname.'").select2({
|
||||
$(".'.$htmlname.'").select2({
|
||||
ajax: {
|
||||
dir: "ltr",
|
||||
url: "'.$url.'",
|
||||
@ -4584,12 +4596,17 @@ class Form
|
||||
});
|
||||
});' : '' ) . '
|
||||
|
||||
});
|
||||
</script>';
|
||||
});
|
||||
</script>';
|
||||
|
||||
|
||||
$out.='<input type="text" class="'.$htmlname.($morecss?' '.$morecss:'').'" '.($moreparam?$moreparam.' ':'').'name="'.$htmlname.'">';
|
||||
|
||||
if ($acceptdelayedhtml)
|
||||
{
|
||||
$delayedhtmlcontent.=$outdelayed;
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.=$outdelayed;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
@ -5157,7 +5174,7 @@ class Form
|
||||
* To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria.
|
||||
*
|
||||
* @param object $object Object to show
|
||||
* @param string $paramid Name of parameter to use to name the id into the URL link
|
||||
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link
|
||||
* @param string $morehtml More html content to output just before the nav bar
|
||||
* @param int $shownav Show Condition (navigation is shown if value is 1)
|
||||
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
|
||||
@ -5192,7 +5209,7 @@ class Form
|
||||
|
||||
$ret.='<div class="inline-block floatleft valignmiddle refid'.(($shownav && ($previous_ref || $next_ref))?' refidpadding':'').'">';
|
||||
|
||||
// For thirdparty and contact, the ref is he id, so we show something else
|
||||
// For thirdparty and contact, the ref is the id, so we show something else
|
||||
if ($object->element == 'societe')
|
||||
{
|
||||
$ret.=dol_htmlentities($object->name);
|
||||
@ -5360,7 +5377,7 @@ class Form
|
||||
else
|
||||
{
|
||||
$nophoto='/public/theme/common/nophoto.png';
|
||||
if (in_array($modulepart,array('userphoto','contact'))) // For module thar are "physical" users
|
||||
if (in_array($modulepart,array('userphoto','contact'))) // For module that are "physical" users
|
||||
{
|
||||
$nophoto='/public/theme/common/user_anonymous.png';
|
||||
if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png';
|
||||
|
||||
@ -106,7 +106,7 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli
|
||||
$ref_prodserv = "";
|
||||
if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
|
||||
{
|
||||
if ($prodser->isservice())
|
||||
if ($prodser->isService())
|
||||
{
|
||||
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
|
||||
}
|
||||
|
||||
@ -854,7 +854,7 @@ function dol_get_fiche_end($notab=0)
|
||||
* Show tab footer of a card
|
||||
*
|
||||
* @param object $object Object to show
|
||||
* @param string $paramid Name of parameter to use to name the id into the URL link
|
||||
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link
|
||||
* @param string $morehtml More html content to output just before the nav bar
|
||||
* @param int $shownav Show Condition (navigation is shown if value is 1)
|
||||
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
|
||||
@ -870,28 +870,67 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
{
|
||||
global $conf, $form, $user, $langs;
|
||||
|
||||
//$showlogo=$object->logo;
|
||||
$showlogo=1;
|
||||
$maxvisiblephotos=1;
|
||||
$showimage=1;
|
||||
$showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0);
|
||||
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
|
||||
$modulepart='societe';
|
||||
$modulepart='unknown';
|
||||
if ($object->element == 'societe') $modulepart='societe';
|
||||
if ($object->element == 'contact') $modulepart='contact';
|
||||
if ($object->element == 'member') $modulepart='memberphoto';
|
||||
if ($object->element == 'user') $modulepart='userphoto';
|
||||
if ($object->element == 'product') $modulepart='product';
|
||||
|
||||
print '<div class="arearef heightref valignmiddle" width="100%">';
|
||||
if ($showlogo) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showphoto($modulepart,$object,0,0,0,'photoref').'</div>';
|
||||
if ($object->element == 'product')
|
||||
{
|
||||
$width=80; $cssclass='photoref';
|
||||
$showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
|
||||
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
|
||||
if ($conf->browser->phone) $maxvisiblephotos=1;
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],1,-$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
else
|
||||
{
|
||||
$nophoto='/public/theme/common/nophoto.png';
|
||||
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="'.DOL_URL_ROOT.$nophoto.'"></div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showphoto($modulepart,$object,0,0,0,'photoref','',1,0,$maxvisiblephotos).'</div>';
|
||||
}
|
||||
if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
|
||||
if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
||||
$morehtmlright.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
|
||||
} else {
|
||||
}
|
||||
elseif ($object->element == 'product')
|
||||
{
|
||||
//$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Sell").') ';
|
||||
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
||||
$morehtmlright.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
|
||||
} else {
|
||||
$morehtmlright.=$object->getLibStatut(2,0);
|
||||
}
|
||||
$morehtmlright.=' ';
|
||||
//$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Buy").') ';
|
||||
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
||||
$morehtmlright.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
|
||||
} else {
|
||||
$morehtmlright.=$object->getLibStatut(2,1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$morehtmlright.=$object->getLibStatut(2);
|
||||
}
|
||||
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>';
|
||||
$morehtmlref.='<div class="refidno">';
|
||||
$morehtmlref.=$object->getBannerAddress('refaddress',$object);
|
||||
$morehtmlref.='</div>';
|
||||
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member')))
|
||||
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty
|
||||
if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>'; // For product
|
||||
if ($object->element != 'product')
|
||||
{
|
||||
$morehtmlref.='<div class="refidno">';
|
||||
$morehtmlref.=$object->getBannerAddress('refaddress',$object);
|
||||
$morehtmlref.='</div>';
|
||||
}
|
||||
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product')))
|
||||
{
|
||||
$morehtmlref.='<div style="clear: both;"></div><div class="refidno">';
|
||||
$morehtmlref.=$langs->trans("TechnicalID").': '.$object->id;
|
||||
@ -5154,6 +5193,10 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
{
|
||||
global $db,$langs;
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
$value=preg_replace('/\*/','%',$value); // Replace * with %
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
|
||||
@ -5225,17 +5268,17 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
/**
|
||||
* Return the filename of file to get the thumbs
|
||||
*
|
||||
* @param string $file Original filename
|
||||
* @param string $file Original filename (full or relative path)
|
||||
* @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini')
|
||||
* @param string $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image.
|
||||
* @return string New file name
|
||||
* @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image.
|
||||
* @return string New file name (full or relative path, including the thumbs/)
|
||||
*/
|
||||
function getImageFileNameForSize($file, $extName, $extImgTarget='')
|
||||
{
|
||||
$dirName = dirname($file);
|
||||
if ($dirName == '.') $dirName='';
|
||||
|
||||
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse
|
||||
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // We remove extension, whatever is its case
|
||||
$fileName = basename($fileName);
|
||||
|
||||
if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':'');
|
||||
@ -5249,5 +5292,5 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
|
||||
$subdir='';
|
||||
if ($extName) $subdir = 'thumbs/';
|
||||
|
||||
return $dirName.$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
|
||||
return ($dirName?$dirName.'/':'').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
curl_setopt($ch, CURLOPT_POST, 0); // GET
|
||||
}
|
||||
|
||||
//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
|
||||
//if USE_PROXY constant set at begin of this method.
|
||||
if ($USE_PROXY)
|
||||
{
|
||||
dol_syslog("getURLContent set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS);
|
||||
|
||||
@ -512,7 +512,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
|
||||
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse
|
||||
$fileName = basename($fileName);
|
||||
$imgThumbName = $dirthumb.'/'.getImageFileNameForSize($file, $extName, $extImgTarget); // Chemin complet du fichier de la vignette
|
||||
//$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file
|
||||
$imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file
|
||||
|
||||
|
||||
// Check if permission are ok
|
||||
//$fp = fopen($imgThumbName, "w");
|
||||
|
||||
@ -515,7 +515,7 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
|
||||
global $conf;
|
||||
|
||||
// Add a background image on document
|
||||
if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image
|
||||
if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image
|
||||
{
|
||||
$pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image
|
||||
$pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height);
|
||||
@ -1166,7 +1166,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
|
||||
$ref_prodserv = "";
|
||||
if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
|
||||
{
|
||||
if ($prodser->isservice())
|
||||
if ($prodser->isService())
|
||||
{
|
||||
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ function product_prepare_head($object)
|
||||
$head[$h][2] = 'referers';
|
||||
$h++;
|
||||
|
||||
if ($object->isproduct() || ($object->isservice() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option)
|
||||
if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option)
|
||||
{
|
||||
if (! empty($conf->stock->enabled) && $user->rights->stock->lire)
|
||||
{
|
||||
|
||||
@ -98,12 +98,12 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?leftmenu=product&type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?type=0', 'Stocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?type=0', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/popuprop.php?leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 6, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 6, __ENTITY__);
|
||||
-- Product - Services
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?leftmenu=service&action=create&type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?leftmenu=service&type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/popuprop.php?leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__);
|
||||
-- Product - Stocks
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3100__+MAX_llx_menu__, 'products', 'stock', 3__+MAX_llx_menu__, '/product/stock/index.php?leftmenu=stock', 'Stock', 0, 'stocks', '$user->rights->stock->lire', '', 2, 3, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3101__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/card.php?action=create', 'MenuNewWarehouse', 1, 'stocks', '$user->rights->stock->creer', '', 2, 0, __ENTITY__);
|
||||
|
||||
@ -1088,7 +1088,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
}
|
||||
if (! empty($conf->propal->enabled))
|
||||
{
|
||||
$newmenu->add("/product/popuprop.php?leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
|
||||
$newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1100,7 +1100,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
$newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire);
|
||||
if (! empty($conf->propal->enabled))
|
||||
{
|
||||
$newmenu->add("/product/popuprop.php?leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
|
||||
$newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
|
||||
{
|
||||
$moduleid=$reg[1];
|
||||
|
||||
// Chargement de la classe
|
||||
// Loading Class
|
||||
$file = $dir."/export_".$moduleid.".modules.php";
|
||||
$classname = "Export".ucfirst($moduleid);
|
||||
|
||||
|
||||
@ -1546,10 +1546,13 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
|
||||
|
||||
// Show sender
|
||||
$posy=42;
|
||||
$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
|
||||
$posx=$this->marge_gauche;
|
||||
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
|
||||
$hautcadre=40;
|
||||
|
||||
$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
|
||||
$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
|
||||
|
||||
|
||||
// Show sender frame
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
@ -1558,19 +1561,19 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetFillColor(230,230,230);
|
||||
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
|
||||
$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
|
||||
// Show sender name
|
||||
$pdf->SetXY($posx+2,$posy+3);
|
||||
$pdf->SetFont('','B', $default_font_size);
|
||||
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
|
||||
$pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
|
||||
$posy=$pdf->getY();
|
||||
|
||||
// Show sender information
|
||||
$pdf->SetXY($posx+2,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
|
||||
$pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
|
||||
|
||||
|
||||
|
||||
@ -1596,9 +1599,9 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target');
|
||||
|
||||
// Show recipient
|
||||
$widthrecbox=100;
|
||||
$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
|
||||
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
|
||||
$posy=42;
|
||||
$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
|
||||
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
|
||||
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ class ModeleImports
|
||||
{
|
||||
$moduleid=$reg[1];
|
||||
|
||||
// Chargement de la classe
|
||||
// Loading Class
|
||||
$file = $dir."/import_".$moduleid.".modules.php";
|
||||
$classname = "Import".ucfirst($moduleid);
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ class modOauth extends DolibarrModules
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->description = "Enable OAuth authentication";
|
||||
$this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version
|
||||
$this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||
$this->special = 1;
|
||||
|
||||
@ -51,7 +51,7 @@ class modReceiptPrinter extends DolibarrModules
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->description = "ReceiptPrinterDesc";
|
||||
$this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
|
||||
$this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||
$this->special = 1;
|
||||
|
||||
@ -30,12 +30,25 @@ use OAuth\Common\Consumer\Credentials;
|
||||
use OAuth\Common\Token\TokenInterface;
|
||||
use OAuth\OAuth2\Service\Google;
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$backtourl = GETPOST('backtourl', 'alpha');
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the URI class with the current URI, stripping the query string
|
||||
*/
|
||||
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
|
||||
$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
|
||||
$currentUri->setQuery('');
|
||||
//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
|
||||
//$currentUri->setQuery('');
|
||||
$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php');
|
||||
|
||||
|
||||
/**
|
||||
* Load the credential for the service
|
||||
@ -43,8 +56,15 @@ $currentUri->setQuery('');
|
||||
|
||||
/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */
|
||||
$serviceFactory = new \OAuth\ServiceFactory();
|
||||
$httpClient = new \OAuth\Common\Http\Client\CurlClient();
|
||||
// TODO Set options for proxy and timeout
|
||||
// $params=array('CURLXXX'=>value, ...)
|
||||
//$httpClient->setCurlParameters($params);
|
||||
$serviceFactory->setHttpClient($httpClient);
|
||||
|
||||
// Dolibarr storage
|
||||
$storage = new DoliStorage($db, $conf);
|
||||
|
||||
// Setup the credentials for the requests
|
||||
$credentials = new Credentials(
|
||||
$conf->global->OAUTH_GOOGLE_ID,
|
||||
@ -52,6 +72,7 @@ $credentials = new Credentials(
|
||||
$currentUri->getAbsoluteUri()
|
||||
);
|
||||
|
||||
|
||||
// Instantiate the Api service using the credentials, http client and storage mechanism for the token
|
||||
/** @var $apiService Service */
|
||||
// TODO remove hardcoded array
|
||||
@ -59,52 +80,71 @@ $apiService = $serviceFactory->createService('Google', $credentials, $storage, a
|
||||
|
||||
// access type needed for google refresh token
|
||||
$apiService->setAccessType('offline');
|
||||
//print '<pre>'.print_r($apiService,true).'</pre>';
|
||||
//print 'Has access Token: '.($storage->hasAccessToken('Google')?'Yes':'No').'</ br>';
|
||||
//print 'Has Author State: '.($storage->hasAuthorizationState('Google')?'Yes':'No').'</ br>';
|
||||
//print 'Authorization State: '.$storage->retrieveAuthorizationState('Google').'</ br>';
|
||||
//print '<td><pre>'.print_r($token,true).'</pre></td>';
|
||||
if (! empty($_GET['code'])) {
|
||||
llxHeader('',$langs->trans("OAuthSetup"));
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
|
||||
$langs->load("oauth");
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$storage->clearToken('Google');
|
||||
|
||||
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
|
||||
|
||||
header('Location: ' . $backtourl);
|
||||
exit();
|
||||
}
|
||||
|
||||
if (! empty($_GET['code'])) // We are coming from Google oauth page
|
||||
{
|
||||
//llxHeader('',$langs->trans("OAuthSetup"));
|
||||
|
||||
//$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
//print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
|
||||
|
||||
//dol_fiche_head();
|
||||
// retrieve the CSRF state parameter
|
||||
$state = isset($_GET['state']) ? $_GET['state'] : null;
|
||||
try {
|
||||
$token = $storage->retrieveAccessToken('Google');
|
||||
} catch (Exception $e) {
|
||||
print $e->getMessage();
|
||||
}
|
||||
//print '<pre>'.print_r($token->getRefreshToken(),true).'</pre>';
|
||||
//$refreshtoken = $token->getRefreshToken();
|
||||
//print '<table>';
|
||||
|
||||
// This was a callback request from service, get the token
|
||||
$apiService->requestAccessToken($_GET['code'], $state);
|
||||
//print '<pre>'.print_r($apiService,true).'</pre>';
|
||||
|
||||
try {
|
||||
$token = $storage->retrieveAccessToken('Google');
|
||||
//var_dump($_GET['code']);
|
||||
//var_dump($state);
|
||||
//var_dump($apiService); // OAuth\OAuth2\Service\Google
|
||||
$token = $apiService->requestAccessToken($_GET['code'], $state);
|
||||
|
||||
setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs');
|
||||
} catch (Exception $e) {
|
||||
print $e->getMessage();
|
||||
}
|
||||
$newrefreshtoken = $token->getRefreshToken();
|
||||
if (empty($newrefreshtoken) && ! empty($refreshtoken)) {
|
||||
$token->setRefreshToken($refreshtoken);
|
||||
$storage->storeAccessToken('Google', $token);
|
||||
}
|
||||
print '<td><pre>'.print_r($token,true).'</pre></td>';
|
||||
//$apiService->refreshAccessToken($token);
|
||||
//print '<pre>'.print_r($apiService,true).'</pre>';
|
||||
//$token = $storage->retrieveAccessToken('Google');
|
||||
//print '<td><pre>'.print_r($token,true).'</pre></td>';
|
||||
|
||||
} else {
|
||||
$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
|
||||
unset($_SESSION["backtourlsavedbeforeoauthjump"]);
|
||||
|
||||
header('Location: ' . $backtourl);
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
|
||||
|
||||
$url = $apiService->getAuthorizationUri();
|
||||
// we go on google authorization page
|
||||
header('Location: ' . $url);
|
||||
exit();
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
// No view at all, just actions
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
@ -87,6 +87,8 @@ class printing_printgcp extends PrintingDriver
|
||||
$this->errors[] = $e->getMessage();
|
||||
$token_ok = false;
|
||||
}
|
||||
//var_dump($this->errors);exit;
|
||||
|
||||
$expire = false;
|
||||
// Is token expired or will token expire in the next 30 seconds
|
||||
if ($token_ok) {
|
||||
@ -116,9 +118,13 @@ class printing_printgcp extends PrintingDriver
|
||||
$refreshtoken = $token->getRefreshToken();
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info');
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info');
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(date("Y-m-d H:i:s", $token->getEndOfLife())), 'type'=>'info');
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(dol_print_date($token->getEndOfLife(), "dayhour")), 'type'=>'info');
|
||||
}
|
||||
if (!$storage->hasAccessToken('Google')) {
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink');
|
||||
} else {
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete');
|
||||
}
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink');
|
||||
} else {
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info');
|
||||
}
|
||||
|
||||
@ -94,8 +94,8 @@ class pdf_beluga extends ModelePDFProjects
|
||||
$this->posxref=$this->marge_gauche+1;
|
||||
$this->posxdate=$this->marge_gauche+25;
|
||||
$this->posxsociety=$this->marge_gauche+45;
|
||||
$this->posxamountht=$this->marge_gauche+115;
|
||||
$this->posxamountttc=$this->marge_gauche+140;
|
||||
$this->posxamountht=$this->marge_gauche+110;
|
||||
$this->posxamountttc=$this->marge_gauche+135;
|
||||
$this->posxstatut=$this->marge_gauche+165;
|
||||
}
|
||||
|
||||
@ -231,14 +231,16 @@ class pdf_beluga extends ModelePDFProjects
|
||||
'class'=>'Propal',
|
||||
'table'=>'propal',
|
||||
'datefieldname'=>'datep',
|
||||
'test'=>$conf->propal->enabled && $user->rights->propale->lire),
|
||||
'test'=>$conf->propal->enabled && $user->rights->propale->lire,
|
||||
'lang'=>'propal'),
|
||||
'order'=>array(
|
||||
'name'=>"CustomersOrders",
|
||||
'title'=>"ListOrdersAssociatedProject",
|
||||
'class'=>'Commande',
|
||||
'table'=>'commande',
|
||||
'datefieldname'=>'date_commande',
|
||||
'test'=>$conf->commande->enabled && $user->rights->commande->lire),
|
||||
'test'=>$conf->commande->enabled && $user->rights->commande->lire,
|
||||
'lang'=>'order'),
|
||||
'invoice'=>array(
|
||||
'name'=>"CustomersInvoices",
|
||||
'title'=>"ListInvoicesAssociatedProject",
|
||||
@ -246,21 +248,24 @@ class pdf_beluga extends ModelePDFProjects
|
||||
'margin'=>'add',
|
||||
'table'=>'facture',
|
||||
'datefieldname'=>'datef',
|
||||
'test'=>$conf->facture->enabled && $user->rights->facture->lire),
|
||||
'test'=>$conf->facture->enabled && $user->rights->facture->lire,
|
||||
'lang'=>'bills'),
|
||||
'invoice_predefined'=>array(
|
||||
'name'=>"PredefinedInvoices",
|
||||
'title'=>"ListPredefinedInvoicesAssociatedProject",
|
||||
'class'=>'FactureRec',
|
||||
'table'=>'facture_rec',
|
||||
'datefieldname'=>'datec',
|
||||
'test'=>$conf->facture->enabled && $user->rights->facture->lire),
|
||||
'test'=>$conf->facture->enabled && $user->rights->facture->lire,
|
||||
'lang'=>'bills'),
|
||||
'order_supplier'=>array(
|
||||
'name'=>"SuppliersOrders",
|
||||
'title'=>"ListSupplierOrdersAssociatedProject",
|
||||
'class'=>'CommandeFournisseur',
|
||||
'table'=>'commande_fournisseur',
|
||||
'datefieldname'=>'date_commande',
|
||||
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire),
|
||||
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire,
|
||||
'lang'=>'orders'),
|
||||
'invoice_supplier'=>array(
|
||||
'name'=>"BillsSuppliers",
|
||||
'title'=>"ListSupplierInvoicesAssociatedProject",
|
||||
@ -268,14 +273,16 @@ class pdf_beluga extends ModelePDFProjects
|
||||
'margin'=>'minus',
|
||||
'table'=>'facture_fourn',
|
||||
'datefieldname'=>'datef',
|
||||
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire),
|
||||
'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire,
|
||||
'lang'=>'bills'),
|
||||
'contract'=>array(
|
||||
'name'=>"Contracts",
|
||||
'title'=>"ListContractAssociatedProject",
|
||||
'class'=>'Contrat',
|
||||
'table'=>'contrat',
|
||||
'datefieldname'=>'date_contrat',
|
||||
'test'=>$conf->contrat->enabled && $user->rights->contrat->lire),
|
||||
'test'=>$conf->contrat->enabled && $user->rights->contrat->lire,
|
||||
'lang'=>'contract'),
|
||||
'intervention'=>array(
|
||||
'name'=>"Interventions",
|
||||
'title'=>"ListFichinterAssociatedProject",
|
||||
@ -283,7 +290,8 @@ class pdf_beluga extends ModelePDFProjects
|
||||
'table'=>'fichinter',
|
||||
'datefieldname'=>'date_valid',
|
||||
'disableamount'=>1,
|
||||
'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire),
|
||||
'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire,
|
||||
'lang'=>'interventions'),
|
||||
'trip'=>array(
|
||||
'name'=>"TripsAndExpenses",
|
||||
'title'=>"ListTripAssociatedProject",
|
||||
@ -292,7 +300,18 @@ class pdf_beluga extends ModelePDFProjects
|
||||
'datefieldname'=>'dated',
|
||||
'margin'=>'minus',
|
||||
'disableamount'=>1,
|
||||
'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire),
|
||||
'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire,
|
||||
'lang'=>'trip'),
|
||||
'expensereport'=>array(
|
||||
'name'=>"ExpensesReports",
|
||||
'title'=>"ListTripAssociatedProject",
|
||||
'class'=>'ExpenseReport',
|
||||
'table'=>'expensereport',
|
||||
'datefieldname'=>'dated',
|
||||
'margin'=>'minus',
|
||||
'disableamount'=>1,
|
||||
'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire,
|
||||
'lang'=>'trip'),
|
||||
'agenda'=>array(
|
||||
'name'=>"Agenda",
|
||||
'title'=>"ListActionsAssociatedProject",
|
||||
@ -300,7 +319,8 @@ class pdf_beluga extends ModelePDFProjects
|
||||
'table'=>'actioncomm',
|
||||
'datefieldname'=>'datep',
|
||||
'disableamount'=>1,
|
||||
'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire)
|
||||
'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read,
|
||||
'lang'=>'agenda')
|
||||
);
|
||||
|
||||
|
||||
@ -311,12 +331,17 @@ class pdf_beluga extends ModelePDFProjects
|
||||
$tablename=$value['table'];
|
||||
$datefieldname=$value['datefieldname'];
|
||||
$qualified=$value['test'];
|
||||
$langstoload=$value['lang'];
|
||||
$langs->load($langstoload);
|
||||
|
||||
if ($qualified)
|
||||
{
|
||||
//var_dump("$key, $tablename, $datefieldname, $dates, $datee");
|
||||
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
|
||||
//var_dump($elementarray);
|
||||
|
||||
$num = count($elementarray);
|
||||
if ($num > 0)
|
||||
if ($num >= 0)
|
||||
{
|
||||
$nexY = $pdf->GetY() + 5;
|
||||
$curY = $nexY;
|
||||
@ -334,9 +359,9 @@ class pdf_beluga extends ModelePDFProjects
|
||||
$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L');
|
||||
if (empty($value['disableamount'])) {
|
||||
$pdf->SetXY($this->posxamountht, $curY);
|
||||
$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHT"), 1, 'R');
|
||||
$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R');
|
||||
$pdf->SetXY($this->posxamountttc, $curY);
|
||||
$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTC"), 1, 'R');
|
||||
$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R');
|
||||
} else {
|
||||
$pdf->SetXY($this->posxamountht, $curY);
|
||||
$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
|
||||
@ -434,8 +459,6 @@ class pdf_beluga extends ModelePDFProjects
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Pied de page
|
||||
*/
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -315,14 +316,39 @@ else {
|
||||
<?php
|
||||
if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
|
||||
{
|
||||
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
|
||||
else $colspan = 9;
|
||||
if($this->situation_cycle_ref) $colspan++;
|
||||
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
|
||||
if (in_array($object->element,array('propal','askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
|
||||
$colspan = 6;
|
||||
|
||||
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
|
||||
$colspan++;
|
||||
}
|
||||
if ($this->situation_cycle_ref) {
|
||||
$colspan++;
|
||||
}
|
||||
// We add 1 if col total ttc
|
||||
if (!empty($inputalsopricewithtax)) {
|
||||
$colspan++;
|
||||
}
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
$colspan++;
|
||||
}
|
||||
if (count($object->lines)) {
|
||||
//There will be an edit and a delete button
|
||||
$colspan += 2;
|
||||
|
||||
// With this, there is a column move button ONLY if lines > 1
|
||||
if (in_array($object->element, array(
|
||||
'propal',
|
||||
'askpricesupplier',
|
||||
'facture',
|
||||
'invoice',
|
||||
'commande',
|
||||
'order',
|
||||
'order_supplier',
|
||||
'invoice_supplier'
|
||||
))) {
|
||||
$colspan++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
@ -508,7 +534,7 @@ jQuery(document).ready(function() {
|
||||
?>
|
||||
|
||||
/* Code for margin */
|
||||
$("#fournprice_predef options").remove();
|
||||
$("#fournprice_predef").find("option").remove();
|
||||
$("#fournprice_predef").hide();
|
||||
$("#buying_price").val("").show();
|
||||
/* Call post to load content of combo list fournprice_predef */
|
||||
|
||||
@ -1048,7 +1048,7 @@ class Expedition extends CommonObject
|
||||
// no lot/serial
|
||||
// We increment stock of product (and sub-products)
|
||||
// We use warehouse selected for each line
|
||||
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr", $this->ref));
|
||||
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref)); // price is set to 0 because we dont want to see WAP changed
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;$this->errors=$this->errors + $mouvS->errors;
|
||||
@ -1061,7 +1061,7 @@ class Expedition extends CommonObject
|
||||
// We use warehouse selected for each line
|
||||
foreach($lotArray as $lot)
|
||||
{
|
||||
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->dluo_qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch);
|
||||
$result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->dluo_qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch); // price is set to 0 because we dont want to see WAP changed
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;$this->errors=$this->errors + $mouvS->errors;
|
||||
|
||||
@ -107,7 +107,7 @@ class Export
|
||||
|
||||
if ($enabled)
|
||||
{
|
||||
// Chargement de la classe
|
||||
// Loading Class
|
||||
$file = $dir.$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once $file;
|
||||
|
||||
@ -481,7 +481,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error='Not Authorized';
|
||||
$this->error='NotAuthorized';
|
||||
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
@ -936,6 +936,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
*/
|
||||
function commande($user, $date, $methode, $comment='')
|
||||
{
|
||||
global $langs;
|
||||
dol_syslog(get_class($this)."::commande");
|
||||
$result = 0;
|
||||
if ($user->rights->fournisseur->commande->commander)
|
||||
@ -946,16 +947,24 @@ class CommandeFournisseur extends CommonOrder
|
||||
dol_syslog(get_class($this)."::commande", LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->statut = 3;
|
||||
$this->methode_commande_id = $methode;
|
||||
$this->date_commande = $this->db->idate($date);
|
||||
$result = 1;
|
||||
$this->log($user, 3, $date, $comment);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$result = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = -1;
|
||||
$this->error = $langs->trans('NotAuthorized');
|
||||
$this->errors[] = $lanfs->trans('NotAuthorized');
|
||||
dol_syslog(get_class($this)."::commande User not Authorized", LOG_ERR);
|
||||
}
|
||||
return $result ;
|
||||
@ -1762,7 +1771,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
*/
|
||||
function Livraison($user, $date, $type, $comment)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
$result = 0;
|
||||
$error = 0;
|
||||
@ -1829,6 +1838,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
if ($resql)
|
||||
{
|
||||
$result = 0;
|
||||
$this->statut = $statut;
|
||||
$result=$this->log($user, $statut, $date, $comment);
|
||||
|
||||
$this->db->commit();
|
||||
@ -1843,6 +1853,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $langs->trans('NotAuthorized');
|
||||
$this->errors[] = $langs->trans('NotAuthorized');
|
||||
dol_syslog(get_class($this)."::Livraison Not Authorized");
|
||||
$result = -3;
|
||||
}
|
||||
@ -1992,6 +2004,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->statut = $status;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -704,15 +704,14 @@ if (empty($reshook))
|
||||
|
||||
if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander)
|
||||
{
|
||||
$result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']);
|
||||
$result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']);
|
||||
if ($result > 0)
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -767,15 +766,15 @@ if (empty($reshook))
|
||||
{
|
||||
$date_liv = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear"));
|
||||
|
||||
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment"));
|
||||
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment"));
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
setEventMessages($langs->trans("DeliveryStateSaved"), null);
|
||||
$action = '';
|
||||
}
|
||||
else if($result == -3)
|
||||
{
|
||||
setEventMessage($langs->trans("NotAuthorized"), 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -273,7 +273,7 @@ if ($resql)
|
||||
if ($search_all)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall));
|
||||
print $langs->transnoentities("FilterOnInto", $search_all, join(', ',$fieldstosearchall));
|
||||
}
|
||||
|
||||
print '<table class="liste" width="100%">';
|
||||
|
||||
@ -257,7 +257,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture);
|
||||
|
||||
$sql = 'SELECT s.nom as name, s.rowid as socid,';
|
||||
$sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total';
|
||||
$sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, fk_mode_reglement, fk_account';
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
@ -292,11 +292,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print $supplierstatic->getNomUrl(1,'supplier');
|
||||
print '</td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
|
||||
$form->select_date($dateinvoice,'','','','',"addpaiement",1,1);
|
||||
$form->select_date($dateinvoice,'','','','',"addpaiement",1,1,0,0,'','',$object->date);
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans('Comments').'</td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('PaymentMode').'</td><td>';
|
||||
$form->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid');
|
||||
$form->select_types_paiements(empty($_POST['paiementid'])?$obj->fk_mode_reglement:$_POST['paiementid'],'paiementid');
|
||||
print '</td>';
|
||||
print '<td rowspan="3" valign="top">';
|
||||
print '<textarea name="comment" wrap="soft" cols="60" rows="'.ROWS_3.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>';
|
||||
@ -304,7 +304,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Account').'</td><td>';
|
||||
$form->select_comptes(empty($accountid)?'':$accountid,'accountid',0,'',2);
|
||||
$form->select_comptes(empty($accountid)?$obj->fk_account:$accountid,'accountid',0,'',2);
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
|
||||
@ -86,6 +86,10 @@ class DoliStorage implements TokenStorageInterface
|
||||
*/
|
||||
public function storeAccessToken($service, TokenInterface $token)
|
||||
{
|
||||
//var_dump("storeAccessToken");
|
||||
//var_dump($token);
|
||||
dol_syslog("storeAccessToken");
|
||||
|
||||
$serializedToken = serialize($token);
|
||||
$this->tokens[$service] = $token;
|
||||
|
||||
@ -95,6 +99,10 @@ class DoliStorage implements TokenStorageInterface
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_token";
|
||||
$sql.= " WHERE service='".$service."' AND entity=1";
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
$obj = $this->db->fetch_array($resql);
|
||||
if ($obj) {
|
||||
// update
|
||||
@ -108,7 +116,8 @@ class DoliStorage implements TokenStorageInterface
|
||||
$sql.= " VALUES ('".$service."', '".$this->db->escape($serializedToken)."', 1)";
|
||||
$resql = $this->db->query($sql);
|
||||
}
|
||||
|
||||
//print $sql;
|
||||
|
||||
// allow chaining
|
||||
return $this;
|
||||
}
|
||||
@ -122,8 +131,13 @@ class DoliStorage implements TokenStorageInterface
|
||||
$sql = "SELECT token FROM ".MAIN_DB_PREFIX."oauth_token";
|
||||
$sql.= " WHERE service='".$service."'";
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
$result = $this->db->fetch_array($resql);
|
||||
$token = unserialize($result[token]);
|
||||
$token = unserialize($result['token']);
|
||||
|
||||
$this->tokens[$service] = $token;
|
||||
|
||||
return is_array($this->tokens)
|
||||
@ -138,14 +152,15 @@ class DoliStorage implements TokenStorageInterface
|
||||
{
|
||||
// TODO
|
||||
// get previously saved tokens
|
||||
$tokens = $this->session->get($this->key);
|
||||
//$tokens = $this->retrieveAccessToken($service);
|
||||
|
||||
if (is_array($tokens) && array_key_exists($service, $tokens)) {
|
||||
unset($tokens[$service]);
|
||||
//if (is_array($tokens) && array_key_exists($service, $tokens)) {
|
||||
// unset($tokens[$service]);
|
||||
|
||||
// Replace the stored tokens array
|
||||
$this->conf->set($this->key, $tokens);
|
||||
}
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token";
|
||||
$sql.= " WHERE service='".$service."'";
|
||||
$resql = $this->db->query($sql);
|
||||
//}
|
||||
|
||||
// allow chaining
|
||||
return $this;
|
||||
@ -182,8 +197,6 @@ class DoliStorage implements TokenStorageInterface
|
||||
public function storeAuthorizationState($service, $state)
|
||||
{
|
||||
// TODO save or update
|
||||
// get previously saved tokens
|
||||
//$states = $this->conf->get($this->stateKey);
|
||||
|
||||
if (!is_array($states)) {
|
||||
$states = array();
|
||||
@ -192,10 +205,26 @@ class DoliStorage implements TokenStorageInterface
|
||||
$states[$service] = $state;
|
||||
$this->states[$service] = $state;
|
||||
|
||||
// save
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_state (service, state, entity)";
|
||||
$sql.= " VALUES ('".$service."', '".$state."', 1)";
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_state";
|
||||
$sql.= " WHERE service='".$service."' AND entity=1";
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
$obj = $this->db->fetch_array($resql);
|
||||
if ($obj) {
|
||||
// update
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."oauth_state";
|
||||
$sql.= " SET state='".$this->db->escape($state)."'";
|
||||
$sql.= " WHERE rowid='".$obj['rowid']."'";
|
||||
$resql = $this->db->query($sql);
|
||||
} else {
|
||||
// save
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_state (service, state, entity)";
|
||||
$sql.= " VALUES ('".$service."', '".$state."', 1)";
|
||||
$resql = $this->db->query($sql);
|
||||
}
|
||||
|
||||
// allow chaining
|
||||
return $this;
|
||||
|
||||
12
htdocs/includes/escpos/.gitignore
vendored
12
htdocs/includes/escpos/.gitignore
vendored
@ -1,12 +0,0 @@
|
||||
# Eclipse files
|
||||
.settings/*
|
||||
.project
|
||||
.buildpath
|
||||
|
||||
# doxygen files
|
||||
doc/html
|
||||
doc/latex
|
||||
doc/doxygen_sqlite3.db
|
||||
|
||||
# composer files
|
||||
vendor/
|
||||
@ -1,851 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* escpos-php, a Thermal receipt printer library, for use with
|
||||
* ESC/POS compatible printers.
|
||||
*
|
||||
* Copyright (c) 2014-2015 Michael Billington <michael.billington@gmail.com>,
|
||||
* incorporating modifications by:
|
||||
* - Roni Saha <roni.cse@gmail.com>
|
||||
* - Gergely Radics <gerifield@ustream.tv>
|
||||
* - Warren Doyle <w.doyle@fuelled.co>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* This class generates ESC/POS printer control commands for compatible printers.
|
||||
* See README.md for a summary of compatible printers and supported commands, and
|
||||
* basic usage.
|
||||
*
|
||||
* See example/demo.php for a detailed print-out demonstrating the range of commands
|
||||
* implemented in this project.
|
||||
*
|
||||
* Note that some functions have not been implemented:
|
||||
* - Set paper sensors
|
||||
* - Select print colour
|
||||
*
|
||||
* Please direct feature requests, bug reports and contributions to escpos-php
|
||||
* on Github:
|
||||
* - https://github.com/mike42/escpos-php
|
||||
*/
|
||||
require_once(dirname(__FILE__) . "/src/EscposImage.php");
|
||||
require_once(dirname(__FILE__) . "/src/PrintBuffer.php");
|
||||
require_once(dirname(__FILE__) . "/src/EscposPrintBuffer.php");
|
||||
require_once(dirname(__FILE__) . "/src/PrintConnector.php");
|
||||
require_once(dirname(__FILE__) . "/src/WindowsPrintConnector.php");
|
||||
require_once(dirname(__FILE__) . "/src/FilePrintConnector.php");
|
||||
require_once(dirname(__FILE__) . "/src/NetworkPrintConnector.php");
|
||||
require_once(dirname(__FILE__) . "/src/AbstractCapabilityProfile.php");
|
||||
require_once(dirname(__FILE__) . "/src/DefaultCapabilityProfile.php");
|
||||
require_once(dirname(__FILE__) . "/src/SimpleCapabilityProfile.php");
|
||||
require_once(dirname(__FILE__) . "/src/EposTepCapabilityProfile.php");
|
||||
require_once(dirname(__FILE__) . "/src/StarCapabilityProfile.php");
|
||||
require_once(dirname(__FILE__) . "/src/P822DCapabilityProfile.php");
|
||||
require_once(dirname(__FILE__) . "/src/CodePage.php");
|
||||
require_once(dirname(__FILE__) . "/src/ImagePrintBuffer.php");
|
||||
|
||||
class Escpos {
|
||||
/* ASCII codes */
|
||||
const NUL = "\x00";
|
||||
const LF = "\x0a";
|
||||
const ESC = "\x1b";
|
||||
const FS = "\x1c";
|
||||
const FF = "\x0c";
|
||||
const GS = "\x1d";
|
||||
const DLE = "\x10";
|
||||
const EOT = "\x04";
|
||||
|
||||
/* Barcode types */
|
||||
const BARCODE_UPCA = 65;
|
||||
const BARCODE_UPCE = 66;
|
||||
const BARCODE_JAN13 = 67;
|
||||
const BARCODE_JAN8 = 68;
|
||||
const BARCODE_CODE39 = 69;
|
||||
const BARCODE_ITF = 70;
|
||||
const BARCODE_CODABAR = 71;
|
||||
const BARCODE_CODE93 = 72;
|
||||
const BARCODE_CODE128 = 73;
|
||||
|
||||
/* Barcode HRI (human-readable interpretation) text position */
|
||||
const BARCODE_TEXT_NONE = 0;
|
||||
const BARCODE_TEXT_ABOVE = 1;
|
||||
const BARCODE_TEXT_BELOW = 2;
|
||||
|
||||
/* Cut types */
|
||||
const CUT_FULL = 65;
|
||||
const CUT_PARTIAL = 66;
|
||||
|
||||
/* Fonts */
|
||||
const FONT_A = 0;
|
||||
const FONT_B = 1;
|
||||
const FONT_C = 2;
|
||||
|
||||
/* Image sizing options */
|
||||
const IMG_DEFAULT = 0;
|
||||
const IMG_DOUBLE_WIDTH = 1;
|
||||
const IMG_DOUBLE_HEIGHT = 2;
|
||||
|
||||
/* Justifications */
|
||||
const JUSTIFY_LEFT = 0;
|
||||
const JUSTIFY_CENTER = 1;
|
||||
const JUSTIFY_RIGHT = 2;
|
||||
|
||||
/* Print mode constants */
|
||||
const MODE_FONT_A = 0;
|
||||
const MODE_FONT_B = 1;
|
||||
const MODE_EMPHASIZED = 8;
|
||||
const MODE_DOUBLE_HEIGHT = 16;
|
||||
const MODE_DOUBLE_WIDTH = 32;
|
||||
const MODE_UNDERLINE = 128;
|
||||
|
||||
/* QR code error correction levels */
|
||||
const QR_ECLEVEL_L = 0;
|
||||
const QR_ECLEVEL_M = 1;
|
||||
const QR_ECLEVEL_Q = 2;
|
||||
const QR_ECLEVEL_H = 3;
|
||||
|
||||
/* QR code models */
|
||||
const QR_MODEL_1 = 1;
|
||||
const QR_MODEL_2 = 2;
|
||||
const QR_MICRO = 3;
|
||||
|
||||
/* Printer statuses */
|
||||
const STATUS_PRINTER = 1;
|
||||
const STATUS_OFFLINE_CAUSE = 2;
|
||||
const STATUS_ERROR_CAUSE = 3;
|
||||
const STATUS_PAPER_ROLL = 4;
|
||||
const STATUS_INK_A = 7;
|
||||
const STATUS_INK_B = 6;
|
||||
const STATUS_PEELER = 8;
|
||||
|
||||
/* Underline */
|
||||
const UNDERLINE_NONE = 0;
|
||||
const UNDERLINE_SINGLE = 1;
|
||||
const UNDERLINE_DOUBLE = 2;
|
||||
|
||||
/**
|
||||
* @var PrintBuffer The printer's output buffer.
|
||||
*/
|
||||
private $buffer;
|
||||
|
||||
/**
|
||||
* @var PrintConnector
|
||||
*/
|
||||
private $connector;
|
||||
|
||||
/**
|
||||
* @var AbstractCapabilityProfile
|
||||
*/
|
||||
private $profile;
|
||||
|
||||
/**
|
||||
* @var int Current character code table
|
||||
*/
|
||||
private $characterTable;
|
||||
|
||||
/**
|
||||
* Construct a new print object
|
||||
*
|
||||
* @param PrintConnector $connector The PrintConnector to send data to. If not set, output is sent to standard output.
|
||||
* @param AbstractCapabilityProfile $profile Supported features of this printer. If not set, the DefaultCapabilityProfile will be used, which is suitable for Epson printers.
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function __construct(PrintConnector $connector = null, AbstractCapabilityProfile $profile = null) {
|
||||
if(is_null($connector)) {
|
||||
if(php_sapi_name() == 'cli') {
|
||||
$connector = new FilePrintConnector("php://stdout");
|
||||
} else {
|
||||
throw new InvalidArgumentException("Argument passed to Escpos::__construct() must implement interface PrintConnector, null given.");
|
||||
}
|
||||
}
|
||||
/* Set connector */
|
||||
$this -> connector = $connector;
|
||||
|
||||
/* Set capability profile */
|
||||
if($profile === null) {
|
||||
$profile = DefaultCapabilityProfile::getInstance();
|
||||
}
|
||||
$this -> profile = $profile;
|
||||
/* Set buffer */
|
||||
$buffer = new EscposPrintBuffer();
|
||||
$this -> buffer = null;
|
||||
$this -> setPrintBuffer($buffer);
|
||||
$this -> initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a barcode.
|
||||
*
|
||||
* @param string $content The information to encode.
|
||||
* @param int $type The barcode standard to output. If not specified, `Escpos::BARCODE_CODE39` will be used. Note that some barcode formats only support specific lengths or sets of characters.
|
||||
* @throws InvalidArgumentException Where the length or characters used in $content is invalid for the requested barcode format.
|
||||
*/
|
||||
function barcode($content, $type = self::BARCODE_CODE39) {
|
||||
/* Validate input */
|
||||
self::validateInteger($type, 65, 73, __FUNCTION__, "Barcode type");
|
||||
$len = strlen($content);
|
||||
switch($type) {
|
||||
case self::BARCODE_UPCA:
|
||||
self::validateInteger($len, 11, 12, __FUNCTION__, "UPCA barcode content length");
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^[0-9]{11,12}$/", "UPCA barcode content");
|
||||
break;
|
||||
case self::BARCODE_UPCE:
|
||||
self::validateIntegerMulti($len, array(array(6, 8), array(11, 12)), __FUNCTION__, "UPCE barcode content length");
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^([0-9]{6,8}|[0-9]{11,12})$/", "UPCE barcode content");
|
||||
break;
|
||||
case self::BARCODE_JAN13:
|
||||
self::validateInteger($len, 12, 13, __FUNCTION__, "JAN13 barcode content length");
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^[0-9]{12,13}$/", "JAN13 barcode content");
|
||||
break;
|
||||
case self::BARCODE_JAN8:
|
||||
self::validateInteger($len, 7, 8, __FUNCTION__, "JAN8 barcode content length");
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^[0-9]{7,8}$/", "JAN8 barcode content");
|
||||
break;
|
||||
case self::BARCODE_CODE39:
|
||||
self::validateInteger($len, 1, 255, __FUNCTION__, "CODE39 barcode content length"); // 255 is a limitation of the "function b" command, not the barcode format.
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^([0-9A-Z \$\%\+\-\.\/]+|\*[0-9A-Z \$\%\+\-\.\/]+\*)$/", "CODE39 barcode content");
|
||||
break;
|
||||
case self::BARCODE_ITF:
|
||||
self::validateInteger($len, 2, 255, __FUNCTION__, "ITF barcode content length"); // 255 is a limitation of the "function b" command, not the barcode format.
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^([0-9]{2})+$/", "ITF barcode content");
|
||||
break;
|
||||
case self::BARCODE_CODABAR:
|
||||
self::validateInteger($len, 1, 255, __FUNCTION__, "Codabar barcode content length"); // 255 is a limitation of the "function b" command, not the barcode format.
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^[A-Da-d][0-9\$\+\-\.\/\:]+[A-Da-d]$/", "Codabar barcode content");
|
||||
break;
|
||||
case self::BARCODE_CODE93:
|
||||
self::validateInteger($len, 1, 255, __FUNCTION__, "Code93 barcode content length"); // 255 is a limitation of the "function b" command, not the barcode format.
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^[\\x00-\\x7F]+$/", "Code93 barcode content");
|
||||
break;
|
||||
case self::BARCODE_CODE128:
|
||||
self::validateInteger($len, 1, 255, __FUNCTION__, "Code128 barcode content length"); // 255 is a limitation of the "function b" command, not the barcode format.
|
||||
// The CODE128 encoder is quite complex, so only a very basic header-check is applied here.
|
||||
self::validateStringRegex($content, __FUNCTION__, "/^\{[A-C][\\x00-\\x7F]+$/", "Code128 barcode content");
|
||||
break;
|
||||
}
|
||||
if(!$this -> profile -> getSupportsBarcodeB()) {
|
||||
// A simpler barcode command which supports fewer codes
|
||||
self::validateInteger($type, 65, 71, __FUNCTION__);
|
||||
$this -> connector -> write(self::GS . "k" . chr($type - 65) . $content . self::NUL);
|
||||
return;
|
||||
}
|
||||
// More advanced function B, used in preference
|
||||
$this -> connector -> write(self::GS . "k" . chr($type) . chr(strlen($content)) . $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an image, using the older "bit image" command. This creates padding on the right of the image,
|
||||
* if its width is not divisible by 8.
|
||||
*
|
||||
* Should only be used if your printer does not support the graphics() command.
|
||||
*
|
||||
* @param EscposImage $img The image to print
|
||||
* @param EscposImage $size Size modifier for the image.
|
||||
*/
|
||||
function bitImage(EscposImage $img, $size = self::IMG_DEFAULT) {
|
||||
self::validateInteger($size, 0, 3, __FUNCTION__);
|
||||
$header = self::dataHeader(array($img -> getWidthBytes(), $img -> getHeight()), true);
|
||||
$this -> connector -> write(self::GS . "v0" . chr($size) . $header);
|
||||
$this -> connector -> write($img -> toRasterFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the underlying buffer. With some connectors, the
|
||||
* job will not actually be sent to the printer until this is called.
|
||||
*/
|
||||
function close() {
|
||||
$this -> connector -> finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cut the paper.
|
||||
*
|
||||
* @param int $mode Cut mode, either Escpos::CUT_FULL or Escpos::CUT_PARTIAL. If not specified, `Escpos::CUT_FULL` will be used.
|
||||
* @param int $lines Number of lines to feed
|
||||
*/
|
||||
function cut($mode = self::CUT_FULL, $lines = 3) {
|
||||
// TODO validation on cut() inputs
|
||||
$this -> connector -> write(self::GS . "V" . chr($mode) . chr($lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print and feed line / Print and feed n lines.
|
||||
*
|
||||
* @param int $lines Number of lines to feed
|
||||
*/
|
||||
function feed($lines = 1) {
|
||||
self::validateInteger($lines, 1, 255, __FUNCTION__);
|
||||
if($lines <= 1) {
|
||||
$this -> connector -> write(self::LF);
|
||||
} else {
|
||||
$this -> connector -> write(self::ESC . "d" . chr($lines));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Some printers require a form feed to release the paper. On most printers, this
|
||||
* command is only useful in page mode, which is not implemented in this driver.
|
||||
*/
|
||||
function feedForm() {
|
||||
$this -> connector -> write(self::FF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print and reverse feed n lines.
|
||||
*
|
||||
* @param int $lines number of lines to feed. If not specified, 1 line will be fed.
|
||||
*/
|
||||
function feedReverse($lines = 1) {
|
||||
self::validateInteger($lines, 1, 255, __FUNCTION__);
|
||||
$this -> connector -> write(self::ESC . "e" . chr($lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number
|
||||
*/
|
||||
function getCharacterTable() {
|
||||
return $this -> characterTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PrintBuffer
|
||||
*/
|
||||
function getPrintBuffer() {
|
||||
return $this -> buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PrintConnector
|
||||
*/
|
||||
function getPrintConnector() {
|
||||
return $this -> connector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractCapabilityProfile
|
||||
*/
|
||||
function getPrinterCapabilityProfile() {
|
||||
return $this -> profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type The type of status to request
|
||||
* @return stdClass Class containing requested status, or null if either no status was received, or your print connector is unable to read from the printer.
|
||||
*/
|
||||
function getPrinterStatus($type = self::STATUS_PRINTER) {
|
||||
self::validateIntegerMulti($type, array(array(1, 4), array(6, 8)), __FUNCTION__);
|
||||
// Determine which flags we are looking for
|
||||
$statusFlags = array(
|
||||
self::STATUS_PRINTER => array(
|
||||
4 => "pulseHigh", // connector pin 3, see pulse().
|
||||
8 => "offline",
|
||||
32 => "waitingForOnlineRecovery",
|
||||
64 => "feedButtonPressed"
|
||||
),
|
||||
self::STATUS_OFFLINE_CAUSE => array(
|
||||
4 => "coverOpen",
|
||||
8 => "paperManualFeed",
|
||||
32 => "paperEnd",
|
||||
64 => "errorOccurred"
|
||||
),
|
||||
self::STATUS_ERROR_CAUSE => array(
|
||||
4 => "recoverableError",
|
||||
8 => "autocutterError",
|
||||
32 => "unrecoverableError",
|
||||
64 => "autorecoverableError"
|
||||
),
|
||||
self::STATUS_PAPER_ROLL => array(
|
||||
4 => "paperNearEnd",
|
||||
32 => "paperNotPresent"
|
||||
),
|
||||
self::STATUS_INK_A => array(
|
||||
4 => "inkNearEnd",
|
||||
8 => "inkEnd",
|
||||
32 => "inkNotPresent",
|
||||
64 => "cleaning"
|
||||
),
|
||||
self::STATUS_INK_B => array(
|
||||
4 => "inkNearEnd",
|
||||
8 => "inkEnd",
|
||||
32 => "inkNotPresent"
|
||||
),
|
||||
self::STATUS_PEELER => array(
|
||||
4 => "labelWaitingForRemoval",
|
||||
32 => "labelPaperNotDetected"
|
||||
)
|
||||
);
|
||||
$flags = $statusFlags[$type];
|
||||
// Clear any previous statuses which haven't been read yet
|
||||
$f = $this -> connector -> read(1);
|
||||
// Make request
|
||||
$reqC = chr($type);
|
||||
switch($type) {
|
||||
// Special cases: These are two-character requests
|
||||
case self::STATUS_INK_A:
|
||||
$reqC = chr(7) . chr(1);
|
||||
break;
|
||||
case self::STATUS_INK_B:
|
||||
$reqC = chr(7) . chr(2);
|
||||
break;
|
||||
case self::STATUS_PEELER:
|
||||
$reqC = chr(8) . chr(3);
|
||||
break;
|
||||
}
|
||||
$this -> connector -> write(self::DLE . self::EOT . $reqC);
|
||||
// Wait for single-character response
|
||||
$f = $this -> connector -> read(1);
|
||||
$i = 0;
|
||||
while($f === false && $i < 50000) {
|
||||
usleep(100);
|
||||
$f = $this -> connector -> read(1);
|
||||
$i++;
|
||||
}
|
||||
if($f === false) {
|
||||
// Timeout
|
||||
return null;
|
||||
}
|
||||
$ret = new stdClass();
|
||||
foreach($flags as $num => $name) {
|
||||
$ret -> $name = (ord($f) & $num) != 0;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an image to the printer.
|
||||
*
|
||||
* Size modifiers are:
|
||||
* - IMG_DEFAULT (leave image at original size)
|
||||
* - IMG_DOUBLE_WIDTH
|
||||
* - IMG_DOUBLE_HEIGHT
|
||||
*
|
||||
* See the example/ folder for detailed examples.
|
||||
*
|
||||
* The function bitImage() takes the same parameters, and can be used if
|
||||
* your printer doesn't support the newer graphics commands.
|
||||
*
|
||||
* @param EscposImage $img The image to print.
|
||||
* @param int $size Output size modifier for the image.
|
||||
*/
|
||||
function graphics(EscposImage $img, $size = self::IMG_DEFAULT) {
|
||||
self::validateInteger($size, 0, 3, __FUNCTION__);
|
||||
$imgHeader = self::dataHeader(array($img -> getWidth(), $img -> getHeight()), true);
|
||||
$tone = '0';
|
||||
$colors = '1';
|
||||
$xm = (($size & self::IMG_DOUBLE_WIDTH) == self::IMG_DOUBLE_WIDTH) ? chr(2) : chr(1);
|
||||
$ym = (($size & self::IMG_DOUBLE_HEIGHT) == self::IMG_DOUBLE_HEIGHT) ? chr(2) : chr(1);
|
||||
$header = $tone . $xm . $ym . $colors . $imgHeader;
|
||||
$this -> wrapperSendGraphicsData('0', 'p', $header . $img -> toRasterFormat());
|
||||
$this -> wrapperSendGraphicsData('0', '2');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize printer. This resets formatting back to the defaults.
|
||||
*/
|
||||
function initialize() {
|
||||
$this -> connector -> write(self::ESC . "@");
|
||||
$this -> characterTable = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a pulse, for opening a cash drawer if one is connected.
|
||||
* The default settings should open an Epson drawer.
|
||||
*
|
||||
* @param int $pin 0 or 1, for pin 2 or pin 5 kick-out connector respectively.
|
||||
* @param int $on_ms pulse ON time, in milliseconds.
|
||||
* @param int $off_ms pulse OFF time, in milliseconds.
|
||||
*/
|
||||
function pulse($pin = 0, $on_ms = 120, $off_ms = 240) {
|
||||
self::validateInteger($pin, 0, 1, __FUNCTION__);
|
||||
self::validateInteger($on_ms, 1, 511, __FUNCTION__);
|
||||
self::validateInteger($off_ms, 1, 511, __FUNCTION__);
|
||||
$this -> connector -> write(self::ESC . "p" . chr($pin + 48) . chr($on_ms / 2) . chr($off_ms / 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the given data as a QR code on the printer.
|
||||
*
|
||||
* @param string $content The content of the code. Numeric data will be more efficiently compacted.
|
||||
* @param int $ec Error-correction level to use. One of Escpos::QR_ECLEVEL_L (default), Escpos::QR_ECLEVEL_M, Escpos::QR_ECLEVEL_Q or Escpos::QR_ECLEVEL_H. Higher error correction results in a less compact code.
|
||||
* @param int $size Pixel size to use. Must be 1-16 (default 3)
|
||||
* @param int $model QR code model to use. Must be one of Escpos::QR_MODEL_1, Escpos::QR_MODEL_2 (default) or Escpos::QR_MICRO (not supported by all printers).
|
||||
*/
|
||||
function qrCode($content, $ec = self::QR_ECLEVEL_L, $size = 3, $model = self::QR_MODEL_2) {
|
||||
self::validateString($content, __FUNCTION__);
|
||||
self::validateInteger($ec, 0, 3, __FUNCTION__);
|
||||
self::validateInteger($size, 1, 16, __FUNCTION__);
|
||||
self::validateInteger($model, 1, 3, __FUNCTION__);
|
||||
if($content == "") {
|
||||
return;
|
||||
}
|
||||
if(!$this -> profile -> getSupportsQrCode()) {
|
||||
// TODO use software rendering via phpqrcode instead
|
||||
throw new Exception("QR codes are not supported on your printer.");
|
||||
}
|
||||
$cn = '1'; // Code type for QR code
|
||||
// Select model: 1, 2 or micro.
|
||||
$this -> wrapperSend2dCodeData(chr(65), $cn, chr(48 + $model) . chr(0));
|
||||
// Set dot size.
|
||||
$this -> wrapperSend2dCodeData(chr(67), $cn, chr($size));
|
||||
// Set error correction level: L, M, Q, or H
|
||||
$this -> wrapperSend2dCodeData(chr(69), $cn, chr(48 + $ec));
|
||||
// Send content & print
|
||||
$this -> wrapperSend2dCodeData(chr(80), $cn, $content, '0');
|
||||
$this -> wrapperSend2dCodeData(chr(81), $cn, '', '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch character table (code page) manually. Used in conjunction with textRaw() to
|
||||
* print special characters which can't be encoded automatically.
|
||||
*
|
||||
* @param int $table The table to select. Available code tables are model-specific.
|
||||
*/
|
||||
function selectCharacterTable($table = 0) {
|
||||
self::validateInteger($table, 0, 255, __FUNCTION__);
|
||||
$supported = $this -> profile -> getSupportedCodePages();
|
||||
if(!isset($supported[$table])) {
|
||||
throw new InvalidArgumentException("There is no code table $table allowed by this printer's capability profile.");
|
||||
}
|
||||
$this -> characterTable = $table;
|
||||
if($this -> profile -> getSupportsStarCommands()) {
|
||||
/* Not an ESC/POS command: STAR printers stash all the extra code pages under a different command. */
|
||||
$this -> connector -> write(self::ESC . self::GS . "t" . chr($table));
|
||||
return;
|
||||
}
|
||||
$this -> connector -> write(self::ESC . "t" . chr($table));
|
||||
}
|
||||
|
||||
/**
|
||||
* Select print mode(s).
|
||||
*
|
||||
* Several MODE_* constants can be OR'd together passed to this function's `$mode` argument. The valid modes are:
|
||||
* - MODE_FONT_A
|
||||
* - MODE_FONT_B
|
||||
* - MODE_EMPHASIZED
|
||||
* - MODE_DOUBLE_HEIGHT
|
||||
* - MODE_DOUBLE_WIDTH
|
||||
* - MODE_UNDERLINE
|
||||
*
|
||||
* @param int $mode The mode to use. Default is Escpos::MODE_FONT_A, with no special formatting. This has a similar effect to running initialize().
|
||||
*/
|
||||
function selectPrintMode($mode = self::MODE_FONT_A) {
|
||||
$allModes = self::MODE_FONT_B | self::MODE_EMPHASIZED | self::MODE_DOUBLE_HEIGHT | self::MODE_DOUBLE_WIDTH | self::MODE_UNDERLINE;
|
||||
if(!is_integer($mode) || $mode < 0 || ($mode & $allModes) != $mode) {
|
||||
throw new InvalidArgumentException("Invalid mode");
|
||||
}
|
||||
|
||||
$this -> connector -> write(self::ESC . "!" . chr($mode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set barcode height.
|
||||
*
|
||||
* @param int $height Height in dots. If not specified, 8 will be used.
|
||||
*/
|
||||
function setBarcodeHeight($height = 8) {
|
||||
self::validateInteger($height, 1, 255, __FUNCTION__);
|
||||
$this -> connector -> write(self::GS . "h" . chr($height));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the position for the Human Readable Interpretation (HRI) of barcode characters.
|
||||
*
|
||||
* @param position $position. Use Escpos::BARCODE_TEXT_NONE to hide the text (default), or any combination of Escpos::BARCODE_TEXT_TOP and Escpos::BARCODE_TEXT_BOTTOM flags to display the text.
|
||||
*/
|
||||
function setBarcodeTextPosition($position = self::BARCODE_TEXT_NONE) {
|
||||
self::validateInteger($position, 0, 3, __FUNCTION__, "Barcode text position");
|
||||
$this -> connector -> write(self::GS . "H" . chr($position));
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn double-strike mode on/off.
|
||||
*
|
||||
* @param boolean $on true for double strike, false for no double strike
|
||||
*/
|
||||
function setDoubleStrike($on = true) {
|
||||
self::validateBoolean($on, __FUNCTION__);
|
||||
$this -> connector -> write(self::ESC . "G". ($on ? chr(1) : chr(0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn emphasized mode on/off.
|
||||
*
|
||||
* @param boolean $on true for emphasis, false for no emphasis
|
||||
*/
|
||||
function setEmphasis($on = true) {
|
||||
self::validateBoolean($on, __FUNCTION__);
|
||||
$this -> connector -> write(self::ESC . "E". ($on ? chr(1) : chr(0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Select font. Most printers have two fonts (Fonts A and B), and some have a third (Font C).
|
||||
*
|
||||
* @param int $font The font to use. Must be either Escpos::FONT_A, Escpos::FONT_B, or Escpos::FONT_C.
|
||||
*/
|
||||
function setFont($font = self::FONT_A) {
|
||||
self::validateInteger($font, 0, 2, __FUNCTION__);
|
||||
$this -> connector -> write(self::ESC . "M" . chr($font));
|
||||
}
|
||||
|
||||
/**
|
||||
* Select justification.
|
||||
*
|
||||
* @param int $justification One of Escpos::JUSTIFY_LEFT, Escpos::JUSTIFY_CENTER, or Escpos::JUSTIFY_RIGHT.
|
||||
*/
|
||||
function setJustification($justification = self::JUSTIFY_LEFT) {
|
||||
self::validateInteger($justification, 0, 2, __FUNCTION__);
|
||||
$this -> connector -> write(self::ESC . "a" . chr($justification));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a different print buffer to the printer. Buffers are responsible for handling text output to the printer.
|
||||
*
|
||||
* @param PrintBuffer $buffer The buffer to use.
|
||||
* @throws InvalidArgumentException Where the buffer is already attached to a different printer.
|
||||
*/
|
||||
function setPrintBuffer(PrintBuffer $buffer) {
|
||||
if($buffer === $this -> buffer) {
|
||||
return;
|
||||
}
|
||||
if($buffer -> getPrinter() != null) {
|
||||
throw new InvalidArgumentException("This buffer is already attached to a printer.");
|
||||
}
|
||||
if($this -> buffer !== null) {
|
||||
$this -> buffer -> setPrinter(null);
|
||||
}
|
||||
$this -> buffer = $buffer;
|
||||
$this -> buffer -> setPrinter($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set black/white reverse mode on or off. In this mode, text is printed white on a black background.
|
||||
*
|
||||
* @param boolean $on True to enable, false to disable.
|
||||
*/
|
||||
function setReverseColors($on = true) {
|
||||
self::validateBoolean($on, __FUNCTION__);
|
||||
$this -> connector -> write(self::GS . "B" . ($on ? chr(1) : chr(0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of text, as a multiple of the normal size.
|
||||
*
|
||||
* @param int $widthMultiplier Multiple of the regular height to use (range 1 - 8)
|
||||
* @param int $heightMultiplier Multiple of the regular height to use (range 1 - 8)
|
||||
*/
|
||||
function setTextSize($widthMultiplier, $heightMultiplier) {
|
||||
self::validateInteger($widthMultiplier, 1, 8, __FUNCTION__);
|
||||
self::validateInteger($heightMultiplier, 1, 8, __FUNCTION__);
|
||||
$c = pow(2,4) * ($widthMultiplier - 1) + ($heightMultiplier - 1);
|
||||
$this -> connector -> write(self::GS . "!" . chr($c));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set underline for printed text.
|
||||
*
|
||||
* Argument can be true/false, or one of UNDERLINE_NONE,
|
||||
* UNDERLINE_SINGLE or UNDERLINE_DOUBLE.
|
||||
*
|
||||
* @param int $underline Either true/false, or one of Escpos::UNDERLINE_NONE, Escpos::UNDERLINE_SINGLE or Escpos::UNDERLINE_DOUBLE. Defaults to Escpos::UNDERLINE_SINGLE.
|
||||
*/
|
||||
function setUnderline($underline = self::UNDERLINE_SINGLE) {
|
||||
/* Map true/false to underline constants */
|
||||
if($underline === true) {
|
||||
$underline = self::UNDERLINE_SINGLE;
|
||||
} else if($underline === false) {
|
||||
$underline = self::UNDERLINE_NONE;
|
||||
}
|
||||
/* Set the underline */
|
||||
self::validateInteger($underline, 0, 2, __FUNCTION__);
|
||||
$this -> connector -> write(self::ESC . "-". chr($underline));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text to the buffer.
|
||||
*
|
||||
* Text should either be followed by a line-break, or feed() should be called
|
||||
* after this to clear the print buffer.
|
||||
*
|
||||
* @param string $str Text to print
|
||||
*/
|
||||
function text($str = "") {
|
||||
self::validateString($str, __FUNCTION__);
|
||||
$this -> buffer -> writeText((string)$str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text to the buffer without attempting to interpret chararacter codes.
|
||||
*
|
||||
* Text should either be followed by a line-break, or feed() should be called
|
||||
* after this to clear the print buffer.
|
||||
*
|
||||
* @param string $str Text to print
|
||||
*/
|
||||
function textRaw($str = "") {
|
||||
self::validateString($str, __FUNCTION__);
|
||||
$this -> buffer -> writeTextRaw((string)$str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for GS ( k, to calculate and send correct data length.
|
||||
*
|
||||
* @param string $fn Function to use
|
||||
* @param string $cn Output code type. Affects available data
|
||||
* @param string $data Data to send.
|
||||
* @param string $m Modifier/variant for function. Often '0' where used.
|
||||
* @throws InvalidArgumentException Where the input lengths are bad.
|
||||
*/
|
||||
private function wrapperSend2dCodeData($fn, $cn, $data = '', $m = '') {
|
||||
if(strlen($m) > 1 || strlen($cn) != 1 || strlen($fn) != 1) {
|
||||
throw new InvalidArgumentException("wrapperSend2dCodeData: cn and fn must be one character each.");
|
||||
}
|
||||
$header = $this -> intLowHigh(strlen($data) + strlen($m) + 2, 2);
|
||||
$this -> connector -> write(self::GS . "(k" . $header . $cn . $fn . $m . $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for GS ( L, to calculate and send correct data length.
|
||||
*
|
||||
* @param string $m Modifier/variant for function. Usually '0'.
|
||||
* @param string $fn Function number to use, as character.
|
||||
* @param string $data Data to send.
|
||||
* @throws InvalidArgumentException Where the input lengths are bad.
|
||||
*/
|
||||
private function wrapperSendGraphicsData($m, $fn, $data = '') {
|
||||
if(strlen($m) != 1 || strlen($fn) != 1) {
|
||||
throw new InvalidArgumentException("wrapperSendGraphicsData: m and fn must be one character each.");
|
||||
}
|
||||
$header = $this -> intLowHigh(strlen($data) + 2, 2);
|
||||
$this -> connector -> write(self::GS . "(L" . $header . $m . $fn . $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert widths and heights to characters. Used before sending graphics to set the size.
|
||||
*
|
||||
* @param array $inputs
|
||||
* @param boolean $long True to use 4 bytes, false to use 2
|
||||
* @return string
|
||||
*/
|
||||
private static function dataHeader(array $inputs, $long = true) {
|
||||
$outp = array();
|
||||
foreach($inputs as $input) {
|
||||
if($long) {
|
||||
$outp[] = Escpos::intLowHigh($input, 2);
|
||||
} else {
|
||||
self::validateInteger($input, 0 , 255, __FUNCTION__);
|
||||
$outp[] = chr($input);
|
||||
}
|
||||
}
|
||||
return implode("", $outp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate two characters for a number: In lower and higher parts, or more parts as needed.
|
||||
* @param int $int Input number
|
||||
* @param int $length The number of bytes to output (1 - 4).
|
||||
*/
|
||||
private static function intLowHigh($input, $length) {
|
||||
$maxInput = (256 << ($length * 8) - 1);
|
||||
self::validateInteger($length, 1, 4, __FUNCTION__);
|
||||
self::validateInteger($input, 0, $maxInput, __FUNCTION__);
|
||||
$outp = "";
|
||||
for($i = 0; $i < $length; $i++) {
|
||||
$outp .= chr($input % 256);
|
||||
$input = (int)($input / 256);
|
||||
}
|
||||
return $outp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an exception if the argument given is not a boolean
|
||||
*
|
||||
* @param boolean $test the input to test
|
||||
* @param string $source the name of the function calling this
|
||||
*/
|
||||
protected static function validateBoolean($test, $source) {
|
||||
if(!($test === true || $test === false)) {
|
||||
throw new InvalidArgumentException("Argument to $source must be a boolean");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an exception if the argument given is not an integer within the specified range
|
||||
*
|
||||
* @param int $test the input to test
|
||||
* @param int $min the minimum allowable value (inclusive)
|
||||
* @param int $max the maximum allowable value (inclusive)
|
||||
* @param string $source the name of the function calling this
|
||||
* @param string $argument the name of the invalid parameter
|
||||
*/
|
||||
protected static function validateInteger($test, $min, $max, $source, $argument = "Argument") {
|
||||
self::validateIntegerMulti($test, array(array($min, $max)), $source, $argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an exception if the argument given is not an integer within one of the specified ranges
|
||||
*
|
||||
* @param int $test the input to test
|
||||
* @param arrray $ranges array of two-item min/max ranges.
|
||||
* @param string $source the name of the function calling this
|
||||
* @param string $source the name of the function calling this
|
||||
* @param string $argument the name of the invalid parameter
|
||||
*/
|
||||
protected static function validateIntegerMulti($test, array $ranges, $source, $argument = "Argument") {
|
||||
if(!is_integer($test)) {
|
||||
throw new InvalidArgumentException("$argument given to $source must be a number, but '$test' was given.");
|
||||
}
|
||||
$match = false;
|
||||
foreach($ranges as $range) {
|
||||
$match |= $test >= $range[0] && $test <= $range[1];
|
||||
}
|
||||
if(!$match) {
|
||||
// Put together a good error "range 1-2 or 4-6"
|
||||
$rangeStr = "range ";
|
||||
for($i = 0; $i < count($ranges); $i++) {
|
||||
$rangeStr .= $ranges[$i][0] . "-" . $ranges[$i][1];
|
||||
if($i == count($ranges) - 1) {
|
||||
continue;
|
||||
} else if($i == count($ranges) - 2) {
|
||||
$rangeStr .= " or ";
|
||||
} else {
|
||||
$rangeStr .= ", ";
|
||||
}
|
||||
}
|
||||
throw new InvalidArgumentException("$argument given to $source must be in $rangeStr, but $test was given.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an exception if the argument given can't be cast to a string
|
||||
*
|
||||
* @param string $test the input to test
|
||||
* @param string $source the name of the function calling this
|
||||
* @param string $argument the name of the invalid parameter
|
||||
*/
|
||||
protected static function validateString($test, $source, $argument = "Argument") {
|
||||
if (is_object($test) && !method_exists($test, '__toString')) {
|
||||
throw new InvalidArgumentException("$argument to $source must be a string");
|
||||
}
|
||||
}
|
||||
|
||||
protected static function validateStringRegex($test, $source, $regex, $argument = "Argument") {
|
||||
if(preg_match($regex, $test) === 0) {
|
||||
throw new InvalidArgumentException("$argument given to $source is invalid. It should match regex '$regex', but '$test' was given.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
escpos-php, a Thermal receipt printer library, for use with
|
||||
ESC/POS compatible printers.
|
||||
|
||||
Copyright (c) 2014-15 Michael Billington <michael.billington@gmail.com>,
|
||||
incorporating modifications by:
|
||||
- Roni Saha <roni.cse@gmail.com>
|
||||
- Gergely Radics <gerifield@ustream.tv>
|
||||
- Warren Doyle <w.doyle@fuelled.co>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@ -1,352 +0,0 @@
|
||||
ESC/POS Print Driver for PHP
|
||||
============================
|
||||
This project implements a subset of Epson's ESC/POS protocol for thermal receipt printers. It allows you to generate and print receipts with basic formatting, cutting, and barcodes on a compatible printer.
|
||||
|
||||
The library was developed to add drop-in support for receipt printing to any PHP app, including web-based point-of-sale (POS) applications.
|
||||
|
||||
Basic usage
|
||||
-----------
|
||||
A "hello world" receipt can be generated easily (Call this `hello-world.php`):
|
||||
```php
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/Escpos.php");
|
||||
$printer = new Escpos();
|
||||
$printer -> text("Hello World!\n");
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
```
|
||||
This would be printed as:
|
||||
```
|
||||
# Networked printer
|
||||
php hello-world.php | nc 10.x.x.x. 9100
|
||||
# Local printer
|
||||
php hello-world.php > /dev/...
|
||||
# Windows local printer
|
||||
php hello-world.php > foo.txt
|
||||
net use LPT1 \\server\printer
|
||||
copy foo.txt LPT1
|
||||
del foo.txt
|
||||
```
|
||||
|
||||
From your web app, you could pass the output directly to a socket if your printer is networked:
|
||||
```php
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/Escpos.php");
|
||||
$connector = new NetworkPrintConnector("10.x.x.x", 9100);
|
||||
$printer = new Escpos($connector);
|
||||
$printer -> text("Hello World!\n");
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
```
|
||||
|
||||
Or to a local printer:
|
||||
```php
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/Escpos.php");
|
||||
$connector = new FilePrintConnector("/dev/ttyS0");
|
||||
$printer = new Escpos($connector);
|
||||
$printer -> text("Hello World!\n");
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
```
|
||||
|
||||
### Basic workflow
|
||||
The library should be initialised with a PrintConnector, which will pass on the data to your printer.
|
||||
Use the table under "Compatibility", or the examples below to choose the appropriate connector for your
|
||||
platform & interface. If no connector is specified, then standard output is used.
|
||||
|
||||
When you have finished using the print object, call `close()` to finalize any data transfers.
|
||||
|
||||
### Tips & examples
|
||||
On Linux, your printer device file will be somewhere like `/dev/lp0` (parallel), `/dev/usb/lp1` (USB), `/dev/ttyUSB0` (USB-Serial), `/dev/ttyS0` (serial).
|
||||
|
||||
On Windows, the device files will be along the lines of `LPT1` (parallel) or `COM1` (serial). Use the `WindowsPrintConnector` to tap into system printing on Windows (eg. [Windows USB](https://github.com/mike42/escpos-php/tree/master/example/interface/windows-usb.php), [SMB](https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php) or [Windows LPT](https://github.com/mike42/escpos-php/tree/master/example/interface/windows-lpt.php)) - this submits print jobs via a queue rather than communicating directly with the printer.
|
||||
|
||||
A complete real-world receipt can be found in the code of [Auth](https://github.com/mike42/Auth) in [ReceiptPrinter.php](https://github.com/mike42/Auth/blob/master/lib/misc/ReceiptPrinter.php). It includes justification, boldness, and a barcode.
|
||||
|
||||
Other examples are located in the [example/](https://github.com/mike42/escpos-php/blob/master/example/) directory.
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
|
||||
### Interfaces and operating systems
|
||||
This driver is known to work with the following OS/interface combinations:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Linux</th>
|
||||
<th>Mac</th>
|
||||
<th>Windows</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Ethernet</th>
|
||||
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</a></td>
|
||||
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</a></td>
|
||||
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>USB</th>
|
||||
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/linux-usb.php">Yes</a></td>
|
||||
<td>Not tested</td>
|
||||
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/windows-usb.php">Yes</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>USB-serial</th>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Serial</th>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Parallel</th>
|
||||
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/windows-lpt.php">Yes</a></td>
|
||||
<td>Not tested</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SMB shared</th>
|
||||
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php">Yes</a></td>
|
||||
<td>No</td>
|
||||
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php">Yes</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### Printers
|
||||
Many thermal receipt printers support ESC/POS to some degree. This driver has been known to work with:
|
||||
|
||||
- EPOS TEP 220M
|
||||
- Epson TM-T88III
|
||||
- Epson TM-T88IV
|
||||
- Epson TM-T70
|
||||
- Epson TM-T82II
|
||||
- Epson TM-T20
|
||||
- Epson TM-T70II
|
||||
- Epson TM-U220
|
||||
- Epson FX-890 (requires `feedForm()` to release paper).
|
||||
- Okipos 80 Plus III
|
||||
- P-822D
|
||||
- SEYPOS PRP-300 (Also marketed as TYSSO PRP-300)
|
||||
- Star TSP-650
|
||||
- Star TUP-592
|
||||
- Xprinter XP-Q800
|
||||
- Zijang NT-58H
|
||||
- Zijang ZJ-5870
|
||||
- Zijang ZJ-5890T (Marketed as POS 5890T)
|
||||
|
||||
If you use any other printer with this code, please let me know so I can add it to the list.
|
||||
|
||||
Available methods
|
||||
-----------------
|
||||
|
||||
### __construct(PrintConnector $connector, AbstractCapabilityProfile $profile)
|
||||
Construct new print object.
|
||||
|
||||
Parameters:
|
||||
- `PrintConnector $connector`: The PrintConnector to send data to. If not set, output is sent to standard output.
|
||||
- `AbstractCapabilityProfile $profile` Supported features of this printer. If not set, the DefaultCapabilityProfile will be used, which is suitable for Epson printers.
|
||||
|
||||
See [example/interface/]("https://github.com/mike42/escpos-php/tree/master/example/interface/) for ways to open connections for different platforms and interfaces.
|
||||
|
||||
### barcode($content, $type)
|
||||
Print a barcode.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `string $content`: The information to encode.
|
||||
- `int $type`: The barcode standard to output. If not specified, `Escpos::BARCODE_CODE39` will be used.
|
||||
|
||||
Currently supported barcode standards are (depending on your printer):
|
||||
|
||||
- `BARCODE_UPCA`
|
||||
- `BARCODE_UPCE`
|
||||
- `BARCODE_JAN13`
|
||||
- `BARCODE_JAN8`
|
||||
- `BARCODE_CODE39`
|
||||
- `BARCODE_ITF`
|
||||
- `BARCODE_CODABAR`
|
||||
|
||||
Note that some barcode standards can only encode numbers, so attempting to print non-numeric codes with them may result in strange behaviour.
|
||||
|
||||
### bitImage(EscposImage $image, $size)
|
||||
See [graphics()](#graphicsescposimage-image-size) below.
|
||||
|
||||
### cut($mode, $lines)
|
||||
Cut the paper.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $mode`: Cut mode, either `Escpos::CUT_FULL` or `Escpos::CUT_PARTIAL`. If not specified, `Escpos::CUT_FULL` will be used.
|
||||
- `int $lines`: Number of lines to feed before cutting. If not specified, 3 will be used.
|
||||
|
||||
### feed($lines)
|
||||
Print and feed line / Print and feed n lines.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $lines`: Number of lines to feed
|
||||
|
||||
### feedForm()
|
||||
Some printers require a form feed to release the paper. On most printers, this command is only useful in page mode, which is not implemented in this driver.
|
||||
|
||||
### feedReverse($lines)
|
||||
Print and reverse feed n lines.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $lines`: number of lines to feed. If not specified, 1 line will be fed.
|
||||
|
||||
### graphics(EscposImage $image, $size)
|
||||
Print an image to the printer.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `EscposImage $img`: The image to print.
|
||||
- `int $size`: Output size modifier for the image.
|
||||
|
||||
Size modifiers are:
|
||||
|
||||
- `IMG_DEFAULT` (leave image at original size)
|
||||
- `IMG_DOUBLE_WIDTH`
|
||||
- `IMG_DOUBLE_HEIGHT`
|
||||
|
||||
A minimal example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$img = new EscposImage("logo.png");
|
||||
$printer -> graphics($img);
|
||||
```
|
||||
|
||||
See the [example/](https://github.com/mike42/escpos-php/blob/master/example/) folder for detailed examples.
|
||||
|
||||
The function [bitImage()](#bitimageescposimage-image-size) takes the same parameters, and can be used if your printer doesn't support the newer graphics commands.
|
||||
|
||||
### initialize()
|
||||
Initialize printer. This resets formatting back to the defaults.
|
||||
|
||||
### pulse($pin, $on_ms, $off_ms)
|
||||
Generate a pulse, for opening a cash drawer if one is connected. The default settings (0, 120, 240) should open an Epson drawer.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $pin`: 0 or 1, for pin 2 or pin 5 kick-out connector respectively.
|
||||
- `int $on_ms`: pulse ON time, in milliseconds.
|
||||
- `int $off_ms`: pulse OFF time, in milliseconds.
|
||||
|
||||
### qrCode($content, $ec, $size, $model)
|
||||
Print the given data as a QR code on the printer.
|
||||
|
||||
- `string $content`: The content of the code. Numeric data will be more efficiently compacted.
|
||||
- `int $ec` Error-correction level to use. One of `Escpos::QR_ECLEVEL_L` (default), `Escpos::QR_ECLEVEL_M`, `Escpos::QR_ECLEVEL_Q` or `Escpos::QR_ECLEVEL_H`. Higher error correction results in a less compact code.
|
||||
- `int $size`: Pixel size to use. Must be 1-16 (default 3)
|
||||
- `int $model`: QR code model to use. Must be one of `Escpos::QR_MODEL_1`, `Escpos::QR_MODEL_2` (default) or `Escpos::QR_MICRO` (not supported by all printers).
|
||||
|
||||
### selectPrintMode($mode)
|
||||
Select print mode(s).
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $mode`: The mode to use. Default is `Escpos::MODE_FONT_A`, with no special formatting. This has a similar effect to running `initialize()`.
|
||||
|
||||
Several MODE_* constants can be OR'd together passed to this function's `$mode` argument. The valid modes are:
|
||||
|
||||
- `MODE_FONT_A`
|
||||
- `MODE_FONT_B`
|
||||
- `MODE_EMPHASIZED`
|
||||
- `MODE_DOUBLE_HEIGHT`
|
||||
- `MODE_DOUBLE_WIDTH`
|
||||
- `MODE_UNDERLINE`
|
||||
|
||||
### setBarcodeHeight($height)
|
||||
Set barcode height.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $height`: Height in dots. If not specified, 8 will be used.
|
||||
|
||||
### setDoubleStrike($on)
|
||||
Turn double-strike mode on/off.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `boolean $on`: true for double strike, false for no double strike.
|
||||
|
||||
### setEmphasis($on)
|
||||
Turn emphasized mode on/off.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `boolean $on`: true for emphasis, false for no emphasis.
|
||||
|
||||
### setFont($font)
|
||||
Select font. Most printers have two fonts (Fonts A and B), and some have a third (Font C).
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $font`: The font to use. Must be either `Escpos::FONT_A`, `Escpos::FONT_B`, or `Escpos::FONT_C`.
|
||||
|
||||
### setJustification($justification)
|
||||
Select justification.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $justification`: One of `Escpos::JUSTIFY_LEFT`, `Escpos::JUSTIFY_CENTER`, or `Escpos::JUSTIFY_RIGHT`.
|
||||
|
||||
### setReverseColors($on)
|
||||
Set black/white reverse mode on or off. In this mode, text is printed white on a black background.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `boolean $on`: True to enable, false to disable.
|
||||
|
||||
### setTextSize($widthMultiplier, $heightMultiplier)
|
||||
Set the size of text, as a multiple of the normal size.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $widthMultiplier`: Multiple of the regular height to use (range 1 - 8).
|
||||
- `int $heightMultiplier`: Multiple of the regular height to use (range 1 - 8).
|
||||
|
||||
### setUnderline($underline)
|
||||
Set underline for printed text.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `int $underline`: Either `true`/`false`, or one of `Escpos::UNDERLINE_NONE`, `Escpos::UNDERLINE_SINGLE` or `Escpos::UNDERLINE_DOUBLE`. Defaults to `Escpos::UNDERLINE_SINGLE`.
|
||||
|
||||
### text($str)
|
||||
Add text to the buffer. Text should either be followed by a line-break, or `feed()` should be called after this.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `string $str`: The string to print.
|
||||
|
||||
Further notes
|
||||
-------------
|
||||
Posts I've written up for people who are learning how to use receipt printers:
|
||||
|
||||
* [What is ESC/POS, and how do I use it?](http://mike.bitrevision.com/blog/what-is-escpos-and-how-do-i-use-it), which documents the output of test.php.
|
||||
* [Setting up an Epson receipt printer](http://mike.bitrevision.com/blog/2014-20-26-setting-up-an-epson-receipt-printer)
|
||||
* [Getting a USB receipt printer working on Linux](http://mike.bitrevision.com/blog/2015-03-getting-a-usb-receipt-printer-working-on-linux)
|
||||
|
||||
Other versions
|
||||
--------------
|
||||
Some forks of this project have been developed by others for specific use cases. Improvements from the following projects have been incorporated into escpos-php:
|
||||
|
||||
- [wdoyle/EpsonESCPOS-PHP](https://github.com/wdoyle/EpsonESCPOS-PHP)
|
||||
- [ronisaha/php-esc-pos](https://github.com/ronisaha/php-esc-pos)
|
||||
|
||||
Vendor documentation
|
||||
--------------------
|
||||
Epson notes that not all of its printers support all ESC/POS features, and includes a table in their documentation:
|
||||
|
||||
* [FAQ about ESC/POS from Epson](http://content.epson.de/fileadmin/content/files/RSD/downloads/escpos.pdf)
|
||||
|
||||
Note that many printers produced by other vendors use the same standard, and are compatible by varying degrees.
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
{
|
||||
"name": "mike42/escpos-php",
|
||||
"type": "library",
|
||||
"description": "Thermal receipt printer library, for use with ESC/POS compatible printers",
|
||||
"homepage": "https://github.com/mike42/escpos-php",
|
||||
"keywords": ["receipt", "print", "escpos", "ESC-POS", "driver"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Billington",
|
||||
"email": "michael.billington@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Roni Saha",
|
||||
"email": "roni.cse@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Gergely Radics",
|
||||
"email": "gerifield@ustream.tv"
|
||||
},
|
||||
{
|
||||
"name": "Warren Doyle",
|
||||
"email": "w.doyle@fuelled.co"
|
||||
},
|
||||
{
|
||||
"name": "vharo",
|
||||
"email": "vharo@geepok.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.5.*"
|
||||
}
|
||||
}
|
||||
975
htdocs/includes/escpos/composer.lock
generated
975
htdocs/includes/escpos/composer.lock
generated
@ -1,975 +0,0 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "fd25f2b816df83dabf03fe7259ad4018",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
"version": "1.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/instantiator.git",
|
||||
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119",
|
||||
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3,<8.0-DEV"
|
||||
},
|
||||
"require-dev": {
|
||||
"athletic/athletic": "~0.1.8",
|
||||
"ext-pdo": "*",
|
||||
"ext-phar": "*",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"squizlabs/php_codesniffer": "2.0.*@ALPHA"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Instantiator\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marco Pivetta",
|
||||
"email": "ocramius@gmail.com",
|
||||
"homepage": "http://ocramius.github.com/"
|
||||
}
|
||||
],
|
||||
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
|
||||
"homepage": "https://github.com/doctrine/instantiator",
|
||||
"keywords": [
|
||||
"constructor",
|
||||
"instantiate"
|
||||
],
|
||||
"time": "2014-10-13 12:58:55"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-docblock",
|
||||
"version": "2.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
|
||||
"reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8",
|
||||
"reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"dflydev/markdown": "~1.0",
|
||||
"erusev/parsedown": "~1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"phpDocumentor": [
|
||||
"src/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mike van Riel",
|
||||
"email": "mike.vanriel@naenius.com"
|
||||
}
|
||||
],
|
||||
"time": "2015-02-03 12:10:50"
|
||||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "1.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5",
|
||||
"reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "^1.0.2",
|
||||
"phpdocumentor/reflection-docblock": "~2.0",
|
||||
"sebastian/comparator": "~1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "~2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Prophecy\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Konstantin Kudryashov",
|
||||
"email": "ever.zet@gmail.com",
|
||||
"homepage": "http://everzet.com"
|
||||
},
|
||||
{
|
||||
"name": "Marcello Duarte",
|
||||
"email": "marcello.duarte@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Highly opinionated mocking framework for PHP 5.3+",
|
||||
"homepage": "https://github.com/phpspec/prophecy",
|
||||
"keywords": [
|
||||
"Double",
|
||||
"Dummy",
|
||||
"fake",
|
||||
"mock",
|
||||
"spy",
|
||||
"stub"
|
||||
],
|
||||
"time": "2015-03-27 19:31:25"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "2.0.15",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "34cc484af1ca149188d0d9e91412191e398e0b67"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/34cc484af1ca149188d0d9e91412191e398e0b67",
|
||||
"reference": "34cc484af1ca149188d0d9e91412191e398e0b67",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-file-iterator": "~1.3",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-token-stream": "~1.3",
|
||||
"sebastian/environment": "~1.0",
|
||||
"sebastian/version": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-xdebug": ">=2.1.4",
|
||||
"phpunit/phpunit": "~4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-dom": "*",
|
||||
"ext-xdebug": ">=2.2.1",
|
||||
"ext-xmlwriter": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
|
||||
"keywords": [
|
||||
"coverage",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-01-24 10:06:35"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
"version": "1.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
|
||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"File/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
|
||||
"keywords": [
|
||||
"filesystem",
|
||||
"iterator"
|
||||
],
|
||||
"time": "2013-10-10 15:34:57"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-text-template",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
||||
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
||||
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"Text/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Simple template engine.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
|
||||
"keywords": [
|
||||
"template"
|
||||
],
|
||||
"time": "2014-01-30 17:20:04"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-timer",
|
||||
"version": "1.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
||||
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
||||
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHP/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Utility class for timing",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-timer/",
|
||||
"keywords": [
|
||||
"timer"
|
||||
],
|
||||
"time": "2013-08-02 07:42:54"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-token-stream",
|
||||
"version": "1.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
|
||||
"reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/db32c18eba00b121c145575fcbcd4d4d24e6db74",
|
||||
"reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Wrapper around PHP's tokenizer extension.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
|
||||
"keywords": [
|
||||
"tokenizer"
|
||||
],
|
||||
"time": "2015-01-17 09:51:32"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "4.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "d6429b0995b24a2d9dfe5587ee3a7071c1161af4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d6429b0995b24a2d9dfe5587ee3a7071c1161af4",
|
||||
"reference": "d6429b0995b24a2d9dfe5587ee3a7071c1161af4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-reflection": "*",
|
||||
"ext-spl": "*",
|
||||
"php": ">=5.3.3",
|
||||
"phpspec/prophecy": "~1.3,>=1.3.1",
|
||||
"phpunit/php-code-coverage": "~2.0,>=2.0.11",
|
||||
"phpunit/php-file-iterator": "~1.3.2",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-timer": "~1.0.2",
|
||||
"phpunit/phpunit-mock-objects": "~2.3",
|
||||
"sebastian/comparator": "~1.1",
|
||||
"sebastian/diff": "~1.1",
|
||||
"sebastian/environment": "~1.2",
|
||||
"sebastian/exporter": "~1.2",
|
||||
"sebastian/global-state": "~1.0",
|
||||
"sebastian/version": "~1.0",
|
||||
"symfony/yaml": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"phpunit/php-invoker": "~1.1"
|
||||
},
|
||||
"bin": [
|
||||
"phpunit"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.5.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "The PHP Unit Testing framework.",
|
||||
"homepage": "https://phpunit.de/",
|
||||
"keywords": [
|
||||
"phpunit",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-03-29 09:24:05"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "2.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "74ffb87f527f24616f72460e54b595f508dccb5c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c",
|
||||
"reference": "74ffb87f527f24616f72460e54b595f508dccb5c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "~1.0,>=1.0.2",
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-text-template": "~1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Mock Object library for PHPUnit",
|
||||
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
|
||||
"keywords": [
|
||||
"mock",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-04-02 05:36:41"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "1dd8869519a225f7f2b9eb663e225298fade819e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e",
|
||||
"reference": "1dd8869519a225f7f2b9eb663e225298fade819e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"sebastian/diff": "~1.2",
|
||||
"sebastian/exporter": "~1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "whatthejeff@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Volker Dusch",
|
||||
"email": "github@wallbash.com"
|
||||
},
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "bschussek@2bepublished.at"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to compare PHP values for equality",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/comparator",
|
||||
"keywords": [
|
||||
"comparator",
|
||||
"compare",
|
||||
"equality"
|
||||
],
|
||||
"time": "2015-01-29 16:28:08"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/diff",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
||||
"reference": "863df9687835c62aa423a22412d26fa2ebde3fd3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3",
|
||||
"reference": "863df9687835c62aa423a22412d26fa2ebde3fd3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kore Nordmann",
|
||||
"email": "mail@kore-nordmann.de"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Diff implementation",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/diff",
|
||||
"keywords": [
|
||||
"diff"
|
||||
],
|
||||
"time": "2015-02-22 15:13:53"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/environment",
|
||||
"version": "1.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||
"reference": "5a8c7d31914337b69923db26c4221b81ff5a196e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e",
|
||||
"reference": "5a8c7d31914337b69923db26c4221b81ff5a196e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Provides functionality to handle HHVM/PHP environments",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/environment",
|
||||
"keywords": [
|
||||
"Xdebug",
|
||||
"environment",
|
||||
"hhvm"
|
||||
],
|
||||
"time": "2015-01-01 10:01:08"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/exporter",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
||||
"reference": "84839970d05254c73cde183a721c7af13aede943"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943",
|
||||
"reference": "84839970d05254c73cde183a721c7af13aede943",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"sebastian/recursion-context": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "whatthejeff@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Volker Dusch",
|
||||
"email": "github@wallbash.com"
|
||||
},
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "bschussek@2bepublished.at"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
},
|
||||
{
|
||||
"name": "Adam Harvey",
|
||||
"email": "aharvey@php.net"
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to export PHP variables for visualization",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/exporter",
|
||||
"keywords": [
|
||||
"export",
|
||||
"exporter"
|
||||
],
|
||||
"time": "2015-01-27 07:23:06"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/global-state",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/global-state.git",
|
||||
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
|
||||
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-uopz": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Snapshotting of global state",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/global-state",
|
||||
"keywords": [
|
||||
"global state"
|
||||
],
|
||||
"time": "2014-10-06 09:23:50"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/recursion-context",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/recursion-context.git",
|
||||
"reference": "3989662bbb30a29d20d9faa04a846af79b276252"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252",
|
||||
"reference": "3989662bbb30a29d20d9faa04a846af79b276252",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "whatthejeff@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
},
|
||||
{
|
||||
"name": "Adam Harvey",
|
||||
"email": "aharvey@php.net"
|
||||
}
|
||||
],
|
||||
"description": "Provides functionality to recursively process PHP variables",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
|
||||
"time": "2015-01-24 09:48:32"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
"version": "1.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/version.git",
|
||||
"reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4",
|
||||
"reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
||||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"time": "2015-02-24 06:35:25"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.6.6",
|
||||
"target-dir": "Symfony/Component/Yaml",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml.git",
|
||||
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/174f009ed36379a801109955fc5a71a49fe62dd4",
|
||||
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Yaml\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-03-30 15:54:10"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"platform-dev": []
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
html: ../Escpos.php escpos.conf
|
||||
doxygen escpos.conf
|
||||
|
||||
latex: html
|
||||
# Do nothing
|
||||
|
||||
clean:
|
||||
rm --preserve-root -Rf html latex doxygen_sqlite3.db
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,26 +0,0 @@
|
||||
Examples
|
||||
--------
|
||||
|
||||
This folder contains a collectoion of feature examples.
|
||||
Generally, demo.php is the fastest way to find out which features your
|
||||
printer supports.
|
||||
|
||||
## Subfolders
|
||||
- `interface/` - contains examples for output interfaces: eg, parallel, serial, USB, network, file-based.
|
||||
- `specific/` - examples made in response to issues & questions. These cover specific languages, printers and interfaces, so hit narrower use cases.
|
||||
|
||||
## List of examples
|
||||
|
||||
Each example prints to standard output, so either edit the print connector, or redirect the output to your printer to see it in action. They are designed for developers: open them in a text editor before you run them!
|
||||
|
||||
- `bit-image.php` - Prints a images to the printer using the older "bit image" commands.
|
||||
- `demo.php` - Demonstrates output using a large subset of availale features.
|
||||
- `qr-code.php` - Prints QR codes, if your printer supports it.
|
||||
- `character-encodings.php` - Shows available character encodings. Change from the DefaultCapabilityProfile to get more useful output for your specific printer.
|
||||
- `graphics.php` - The same output as `bit-image.php`, printed with the newer graphics commands (not supported on many non-Epson printers)
|
||||
- `receipt-with-logo.php` - A simple receipt containing a logo and basic formating.
|
||||
- `character-encodings-with-images.php` - The same as `character-encodings.php`, but also prints each string using an `ImagePrintBuffer`, showing compatibility gaps.
|
||||
- `print-from-html.php` - Runs `wkhtmltoimage` to convert HTML to an image, and then prints the image. (This is very slow)
|
||||
- `character-tables.php` - Prints a compact character code table for each available character set. Used to debug incorrect output from `character-encodings.php`.
|
||||
- `print-from-pdf.php` - Loads a PDF and prints each page in a few different ways (very slow as well)
|
||||
|
||||
@ -1,181 +0,0 @@
|
||||
<?php
|
||||
require_once (dirname ( __FILE__ ) . "/../Escpos.php");
|
||||
$printer = new Escpos ();
|
||||
$printer->setBarcodeHeight ( 40 );
|
||||
|
||||
/* Text position */
|
||||
$printer->selectPrintMode ( Escpos::MODE_DOUBLE_HEIGHT | Escpos::MODE_DOUBLE_WIDTH );
|
||||
$printer->text ( "Text position\n" );
|
||||
$printer->selectPrintMode ();
|
||||
$hri = array (
|
||||
Escpos::BARCODE_TEXT_NONE => "No text",
|
||||
Escpos::BARCODE_TEXT_ABOVE => "Above",
|
||||
Escpos::BARCODE_TEXT_BELOW => "Below",
|
||||
Escpos::BARCODE_TEXT_ABOVE | Escpos::BARCODE_TEXT_BELOW => "Both"
|
||||
);
|
||||
foreach ( $hri as $position => $caption ) {
|
||||
$printer->text ( $caption . "\n" );
|
||||
$printer->setBarcodeTextPosition ( $position );
|
||||
$printer->barcode ( "012345678901", Escpos::BARCODE_JAN13 );
|
||||
$printer->feed ();
|
||||
}
|
||||
|
||||
/* Barcode types */
|
||||
$standards = array (
|
||||
Escpos::BARCODE_UPCA => array (
|
||||
"title" => "UPC-A",
|
||||
"caption" => "Fixed-length numeric product barcodes.",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "12 char numeric including (wrong) check digit.",
|
||||
"content" => "012345678901"
|
||||
),
|
||||
array (
|
||||
"caption" => "Send 11 chars to add check digit automatically.",
|
||||
"content" => "01234567890"
|
||||
)
|
||||
)
|
||||
),
|
||||
Escpos::BARCODE_UPCE => array (
|
||||
"title" => "UPC-E",
|
||||
"caption" => "Fixed-length numeric compact product barcodes.",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "6 char numeric - auto check digit & NSC",
|
||||
"content" => "123456"
|
||||
),
|
||||
array (
|
||||
"caption" => "7 char numeric - auto check digit",
|
||||
"content" => "0123456"
|
||||
),
|
||||
array (
|
||||
"caption" => "8 char numeric",
|
||||
"content" => "01234567"
|
||||
),
|
||||
array (
|
||||
"caption" => "11 char numeric - auto check digit",
|
||||
"content" => "01234567890"
|
||||
),
|
||||
array (
|
||||
"caption" => "12 char numeric including (wrong) check digit",
|
||||
"content" => "012345678901"
|
||||
)
|
||||
)
|
||||
),
|
||||
Escpos::BARCODE_JAN13 => array (
|
||||
"title" => "JAN13/EAN13",
|
||||
"caption" => "Fixed-length numeric barcodes.",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "12 char numeric - auto check digit",
|
||||
"content" => "012345678901"
|
||||
),
|
||||
array (
|
||||
"caption" => "13 char numeric including (wrong) check digit",
|
||||
"content" => "0123456789012"
|
||||
)
|
||||
)
|
||||
),
|
||||
Escpos::BARCODE_JAN8 => array (
|
||||
"title" => "JAN8/EAN8",
|
||||
"caption" => "Fixed-length numeric barcodes.",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "7 char numeric - auto check digit",
|
||||
"content" => "0123456"
|
||||
),
|
||||
array (
|
||||
"caption" => "8 char numeric including (wrong) check digit",
|
||||
"content" => "01234567"
|
||||
)
|
||||
)
|
||||
),
|
||||
Escpos::BARCODE_CODE39 => array (
|
||||
"title" => "Code39",
|
||||
"caption" => "Variable length alphanumeric w/ some special chars.",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "Text, numbers, spaces",
|
||||
"content" => "ABC 012"
|
||||
),
|
||||
array (
|
||||
"caption" => "Special characters",
|
||||
"content" => "$%+-./"
|
||||
),
|
||||
array (
|
||||
"caption" => "Extra char (*) Used as start/stop",
|
||||
"content" => "*TEXT*"
|
||||
)
|
||||
)
|
||||
),
|
||||
Escpos::BARCODE_ITF => array (
|
||||
"title" => "ITF",
|
||||
"caption" => "Variable length numeric w/even number of digits,\nas they are encoded in pairs.",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "Numeric- even number of digits",
|
||||
"content" => "0123456789"
|
||||
)
|
||||
)
|
||||
),
|
||||
Escpos::BARCODE_CODABAR => array (
|
||||
"title" => "Codabar",
|
||||
"caption" => "Varaible length numeric with some allowable\nextra characters. ABCD/abcd must be used as\nstart/stop characters (one at the start, one\nat the end) to distinguish between barcode\napplications.",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "Numeric w/ A A start/stop. ",
|
||||
"content" => "A012345A"
|
||||
),
|
||||
array (
|
||||
"caption" => "Extra allowable characters",
|
||||
"content" => "A012$+-./:A"
|
||||
)
|
||||
)
|
||||
),
|
||||
Escpos::BARCODE_CODE93 => array (
|
||||
"title" => "Code93",
|
||||
"caption" => "Variable length- any ASCII is available",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "Text",
|
||||
"content" => "012abcd"
|
||||
)
|
||||
)
|
||||
),
|
||||
Escpos::BARCODE_CODE128 => array (
|
||||
"title" => "Code128",
|
||||
"caption" => "Variable length- any ASCII is available",
|
||||
"example" => array (
|
||||
array (
|
||||
"caption" => "Code set A uppercase & symbols",
|
||||
"content" => "{A" . "012ABCD"
|
||||
),
|
||||
array (
|
||||
"caption" => "Code set B general text",
|
||||
"content" => "{B" . "012ABCDabcd"
|
||||
),
|
||||
array (
|
||||
"caption" => "Code set C compact numbers\n Sending chr(21) chr(32) chr(43)",
|
||||
"content" => "{C" . chr ( 21 ) . chr ( 32 ) . chr ( 43 )
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$printer->setBarcodeTextPosition ( Escpos::BARCODE_TEXT_BELOW );
|
||||
foreach ( $standards as $type => $standard ) {
|
||||
$printer->selectPrintMode ( Escpos::MODE_DOUBLE_HEIGHT | Escpos::MODE_DOUBLE_WIDTH );
|
||||
$printer->text ( $standard ["title"] . "\n" );
|
||||
$printer->selectPrintMode ();
|
||||
$printer->text ( $standard ["caption"] . "\n\n" );
|
||||
foreach ( $standard ["example"] as $id => $barcode ) {
|
||||
$printer->setEmphasis ( true );
|
||||
$printer->text ( $barcode ["caption"] . "\n" );
|
||||
$printer->setEmphasis ( false );
|
||||
$printer->text ( "Content: " . $barcode ["content"] . "\n" );
|
||||
$printer->barcode ( $barcode ["content"], $type );
|
||||
$printer->feed ();
|
||||
}
|
||||
}
|
||||
$printer->cut ();
|
||||
$printer->close ();
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/* Example print-outs using the older bit image print command */
|
||||
require_once(dirname(__FILE__) . "/../Escpos.php");
|
||||
$printer = new Escpos();
|
||||
|
||||
try {
|
||||
$tux = new EscposImage("resources/tux.png");
|
||||
|
||||
$printer -> text("These example images are printed with the older\nbit image print command. You should only use\n\$p -> bitImage() if \$p -> graphics() does not\nwork on your printer.\n\n");
|
||||
|
||||
$printer -> bitImage($tux);
|
||||
$printer -> text("Regular Tux (bit image).\n");
|
||||
$printer -> feed();
|
||||
|
||||
$printer -> bitImage($tux, Escpos::IMG_DOUBLE_WIDTH);
|
||||
$printer -> text("Wide Tux (bit image).\n");
|
||||
$printer -> feed();
|
||||
|
||||
$printer -> bitImage($tux, Escpos::IMG_DOUBLE_HEIGHT);
|
||||
$printer -> text("Tall Tux (bit image).\n");
|
||||
$printer -> feed();
|
||||
|
||||
$printer -> bitImage($tux, Escpos::IMG_DOUBLE_WIDTH | Escpos::IMG_DOUBLE_HEIGHT);
|
||||
$printer -> text("Large Tux in correct proportion (bit image).\n");
|
||||
} catch(Exception $e) {
|
||||
/* Images not supported on your PHP, or image file not found */
|
||||
$printer -> text($e -> getMessage() . "\n");
|
||||
}
|
||||
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
?>
|
||||
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
/* Change to the correct path if you copy this example! */
|
||||
require_once(dirname(__FILE__) . "/../Escpos.php");
|
||||
|
||||
/**
|
||||
* This example builds on character-encodings.php, also providing an image-based rendering.
|
||||
* This is quite slow, since a) the buffers are changed dozens of
|
||||
* times in the example, and b) It involves sending very wide images, which printers don't like!
|
||||
*
|
||||
* There are currently no test cases around the image printing, since it is an experimental feature.
|
||||
*
|
||||
* It does, however, illustrate the way that more encodings are available when image output is used.
|
||||
*/
|
||||
include(dirname(__FILE__) . '/resources/character-encoding-test-strings.inc');
|
||||
|
||||
try {
|
||||
// Enter connector and capability profile
|
||||
$connector = new FilePrintConnector("php://stdout");
|
||||
$profile = DefaultCapabilityProfile::getInstance();
|
||||
$buffers = array(new EscposPrintBuffer(), new ImagePrintBuffer());
|
||||
|
||||
/* Print a series of receipts containing i18n example strings */
|
||||
$printer = new Escpos($connector, $profile);
|
||||
$printer -> selectPrintMode(Escpos::MODE_DOUBLE_HEIGHT | Escpos::MODE_EMPHASIZED | Escpos::MODE_DOUBLE_WIDTH);
|
||||
$printer -> text("Implemented languages\n");
|
||||
$printer -> selectPrintMode();
|
||||
foreach($inputsOk as $label => $str) {
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> text($label . ":\n");
|
||||
$printer -> setEmphasis(false);
|
||||
foreach($buffers as $buffer) {
|
||||
$printer -> setPrintBuffer($buffer);
|
||||
$printer -> text($str);
|
||||
}
|
||||
$printer -> setPrintBuffer($buffers[0]);
|
||||
}
|
||||
$printer -> feed();
|
||||
|
||||
$printer -> selectPrintMode(Escpos::MODE_DOUBLE_HEIGHT | Escpos::MODE_EMPHASIZED | Escpos::MODE_DOUBLE_WIDTH);
|
||||
$printer -> text("Works in progress\n");
|
||||
$printer -> selectPrintMode();
|
||||
foreach($inputsNotOk as $label => $str) {
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> text($label . ":\n");
|
||||
$printer -> setEmphasis(false);
|
||||
foreach($buffers as $buffer) {
|
||||
$printer -> setPrintBuffer($buffer);
|
||||
$printer -> text($str);
|
||||
}
|
||||
$printer -> setPrintBuffer($buffers[0]);
|
||||
}
|
||||
$printer -> cut();
|
||||
|
||||
/* Close printer */
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
|
||||
}
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
/* Change to the correct path if you copy this example! */
|
||||
require_once(dirname(__FILE__) . "/../Escpos.php");
|
||||
|
||||
/**
|
||||
* This demonstrates available character encodings. Escpos-php accepts UTF-8,
|
||||
* and converts this to lower-level data to the printer. This is a complex area, so be
|
||||
* prepared to code a model-specific hack ('CapabilityProfile') for your printer.
|
||||
*
|
||||
* If you run into trouble, please file an issue on GitHub, including at a minimum:
|
||||
* - A UTF-8 test string in the language you're working in, and
|
||||
* - A test print or link to a technical document which lists the available
|
||||
* code pages ('character code tables') for your printer.
|
||||
*
|
||||
* The DefaultCapabilityProfile works for Espson-branded printers. For other models, you
|
||||
* must use/create a PrinterCapabilityProfile for your printer containing a list of code
|
||||
* page numbers for your printer- otherwise you will get mojibake.
|
||||
*
|
||||
* If you do not intend to use non-English characters, then use SimpleCapabilityProfile,
|
||||
* which has only the default encoding, effectively disabling code page changes.
|
||||
*/
|
||||
|
||||
include(dirname(__FILE__) . '/resources/character-encoding-test-strings.inc');
|
||||
try {
|
||||
// Enter connector and capability profile (to match your printer)
|
||||
$connector = new FilePrintConnector("php://stdout");
|
||||
$profile = DefaultCapabilityProfile::getInstance();
|
||||
|
||||
/* Print a series of receipts containing i18n example strings */
|
||||
$printer = new Escpos($connector, $profile);
|
||||
$printer -> selectPrintMode(Escpos::MODE_DOUBLE_HEIGHT | Escpos::MODE_EMPHASIZED | Escpos::MODE_DOUBLE_WIDTH);
|
||||
$printer -> text("Implemented languages\n");
|
||||
$printer -> selectPrintMode();
|
||||
foreach($inputsOk as $label => $str) {
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> text($label . ":\n");
|
||||
$printer -> setEmphasis(false);
|
||||
$printer -> text($str);
|
||||
}
|
||||
$printer -> feed();
|
||||
|
||||
$printer -> selectPrintMode(Escpos::MODE_DOUBLE_HEIGHT | Escpos::MODE_EMPHASIZED | Escpos::MODE_DOUBLE_WIDTH);
|
||||
$printer -> text("Works in progress\n");
|
||||
$printer -> selectPrintMode();
|
||||
foreach($inputsNotOk as $label => $str) {
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> text($label . ":\n");
|
||||
$printer -> setEmphasis(false);
|
||||
$printer -> text($str);
|
||||
}
|
||||
$printer -> cut();
|
||||
|
||||
/* Close printer */
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
|
||||
}
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This demo prints out supported code pages on your printer. This is intended
|
||||
* for debugging character-encoding issues: If your printer does not work with
|
||||
* a built-in capability profile, you need to check its documentation for
|
||||
* supported code pages.
|
||||
*
|
||||
* These are then loaded into a capability profile, which maps code page
|
||||
* numbers to iconv encoding names on your particular printer. This script
|
||||
* will print all configured code pages, so that you can check that the chosen
|
||||
* iconv encoding name matches the actual code page contents.
|
||||
*
|
||||
* If this is correctly set up for your printer, then the driver will try its
|
||||
* best to map UTF-8 text into these code pages for you, allowing you to accept
|
||||
* arbitrary input from a database, without worrying about encoding it for the printer.
|
||||
*/
|
||||
require_once(dirname(__FILE__) . "/../Escpos.php");
|
||||
|
||||
// Enter connector and capability profile (to match your printer)
|
||||
$connector = new FilePrintConnector("php://stdout");
|
||||
$profile = DefaultCapabilityProfile::getInstance();
|
||||
$verbose = false; // Skip tables which iconv wont convert to (ie, only print characters available with UTF-8 input)
|
||||
|
||||
/* Print a series of receipts containing i18n example strings - Code below shouldn't need changing */
|
||||
$printer = new Escpos($connector, $profile);
|
||||
$codePages = $profile -> getSupportedCodePages();
|
||||
$first = true; // Print larger table for first code-page.
|
||||
foreach($codePages as $table => $name) {
|
||||
/* Change printer code page */
|
||||
$printer -> selectCharacterTable(255);
|
||||
$printer -> selectCharacterTable($table);
|
||||
/* Select & print a label for it */
|
||||
$label = $name;
|
||||
if($name === false) {
|
||||
$label= " (not matched to iconv table)";
|
||||
}
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> textRaw("Table $table: $label\n");
|
||||
$printer -> setEmphasis(false);
|
||||
if($name === false && !$verbose) {
|
||||
continue; // Skip non-recognised
|
||||
}
|
||||
/* Print a table of available characters (first table is larger than subsequent ones */
|
||||
if($first) {
|
||||
$first = false;
|
||||
compactCharTable($printer, 1, true);
|
||||
} else {
|
||||
compactCharTable($printer);
|
||||
}
|
||||
}
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
|
||||
function compactCharTable($printer, $start = 4, $header = false) {
|
||||
/* Output a compact character table for the current encoding */
|
||||
$chars = str_repeat(' ', 256);
|
||||
for($i = 0; $i < 255; $i++) {
|
||||
$chars[$i] = ($i > 32 && $i != 127) ? chr($i) : ' ';
|
||||
}
|
||||
if($header) {
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> textRaw(" 0123456789ABCDEF0123456789ABCDEF\n");
|
||||
$printer -> setEmphasis(false);
|
||||
}
|
||||
for($y = $start; $y < 8; $y++) {
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> textRaw(strtoupper(dechex($y * 2)) . " ");
|
||||
$printer -> setEmphasis(false);
|
||||
$printer -> textRaw(substr($chars, $y * 32, 32) . "\n");
|
||||
}
|
||||
}
|
||||
@ -1,167 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This is a demo script for the functions of the PHP ESC/POS print driver,
|
||||
* Escpos.php.
|
||||
*
|
||||
* Most printers implement only a subset of the functionality of the driver, so
|
||||
* will not render this output correctly in all cases.
|
||||
*
|
||||
* @author Michael Billington <michael.billington@gmail.com>
|
||||
*/
|
||||
require_once(dirname(__FILE__) . "/../Escpos.php");
|
||||
$printer = new Escpos();
|
||||
|
||||
/* Initialize */
|
||||
$printer -> initialize();
|
||||
|
||||
/* Text */
|
||||
$printer -> text("Hello world\n");
|
||||
$printer -> cut();
|
||||
|
||||
/* Line feeds */
|
||||
$printer -> text("ABC");
|
||||
$printer -> feed(7);
|
||||
$printer -> text("DEF");
|
||||
$printer -> feedReverse(3);
|
||||
$printer -> text("GHI");
|
||||
$printer -> feed();
|
||||
$printer -> cut();
|
||||
|
||||
/* Font modes */
|
||||
$modes = array(
|
||||
Escpos::MODE_FONT_B,
|
||||
Escpos::MODE_EMPHASIZED,
|
||||
Escpos::MODE_DOUBLE_HEIGHT,
|
||||
Escpos::MODE_DOUBLE_WIDTH,
|
||||
Escpos::MODE_UNDERLINE);
|
||||
for($i = 0; $i < pow(2, count($modes)); $i++) {
|
||||
$bits = str_pad(decbin($i), count($modes), "0", STR_PAD_LEFT);
|
||||
$mode = 0;
|
||||
for($j = 0; $j < strlen($bits); $j++) {
|
||||
if(substr($bits, $j, 1) == "1") {
|
||||
$mode |= $modes[$j];
|
||||
}
|
||||
}
|
||||
$printer -> selectPrintMode($mode);
|
||||
$printer -> text("ABCDEFGHIJabcdefghijk\n");
|
||||
}
|
||||
$printer -> selectPrintMode(); // Reset
|
||||
$printer -> cut();
|
||||
|
||||
/* Underline */
|
||||
for($i = 0; $i < 3; $i++) {
|
||||
$printer -> setUnderline($i);
|
||||
$printer -> text("The quick brown fox jumps over the lazy dog\n");
|
||||
}
|
||||
$printer -> setUnderline(0); // Reset
|
||||
$printer -> cut();
|
||||
|
||||
/* Cuts */
|
||||
$printer -> text("Partial cut\n(not available on all printers)\n");
|
||||
$printer -> cut(Escpos::CUT_PARTIAL);
|
||||
$printer -> text("Full cut\n");
|
||||
$printer -> cut(Escpos::CUT_FULL);
|
||||
|
||||
/* Emphasis */
|
||||
for($i = 0; $i < 2; $i++) {
|
||||
$printer -> setEmphasis($i == 1);
|
||||
$printer -> text("The quick brown fox jumps over the lazy dog\n");
|
||||
}
|
||||
$printer -> setEmphasis(false); // Reset
|
||||
$printer -> cut();
|
||||
|
||||
/* Double-strike (looks basically the same as emphasis) */
|
||||
for($i = 0; $i < 2; $i++) {
|
||||
$printer -> setDoubleStrike($i == 1);
|
||||
$printer -> text("The quick brown fox jumps over the lazy dog\n");
|
||||
}
|
||||
$printer -> setDoubleStrike(false);
|
||||
$printer -> cut();
|
||||
|
||||
/* Fonts (many printers do not have a 'Font C') */
|
||||
$fonts = array(
|
||||
Escpos::FONT_A,
|
||||
Escpos::FONT_B,
|
||||
Escpos::FONT_C);
|
||||
for($i = 0; $i < count($fonts); $i++) {
|
||||
$printer -> setFont($fonts[$i]);
|
||||
$printer -> text("The quick brown fox jumps over the lazy dog\n");
|
||||
}
|
||||
$printer -> setFont(); // Reset
|
||||
$printer -> cut();
|
||||
|
||||
/* Justification */
|
||||
$justification = array(
|
||||
Escpos::JUSTIFY_LEFT,
|
||||
Escpos::JUSTIFY_CENTER,
|
||||
Escpos::JUSTIFY_RIGHT);
|
||||
for($i = 0; $i < count($justification); $i++) {
|
||||
$printer -> setJustification($justification[$i]);
|
||||
$printer -> text("A man a plan a canal panama\n");
|
||||
}
|
||||
$printer -> setJustification(); // Reset
|
||||
$printer -> cut();
|
||||
|
||||
/* Barcodes - see barcode.php for more detail */
|
||||
$printer -> setBarcodeHeight(80);
|
||||
$printer->setBarcodeTextPosition ( Escpos::BARCODE_TEXT_BELOW );
|
||||
$printer -> barcode("9876");
|
||||
$printer -> feed();
|
||||
$printer -> cut();
|
||||
|
||||
/* Graphics - this demo will not work on some non-Epson printers */
|
||||
try {
|
||||
$logo = new EscposImage("resources/escpos-php.png");
|
||||
$imgModes = array(
|
||||
Escpos::IMG_DEFAULT,
|
||||
Escpos::IMG_DOUBLE_WIDTH,
|
||||
Escpos::IMG_DOUBLE_HEIGHT,
|
||||
Escpos::IMG_DOUBLE_WIDTH | Escpos::IMG_DOUBLE_HEIGHT
|
||||
);
|
||||
foreach($imgModes as $mode) {
|
||||
$printer -> graphics($logo, $mode);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
/* Images not supported on your PHP, or image file not found */
|
||||
$printer -> text($e -> getMessage() . "\n");
|
||||
}
|
||||
$printer -> cut();
|
||||
|
||||
/* Bit image */
|
||||
try {
|
||||
$logo = new EscposImage("resources/escpos-php.png");
|
||||
$imgModes = array(
|
||||
Escpos::IMG_DEFAULT,
|
||||
Escpos::IMG_DOUBLE_WIDTH,
|
||||
Escpos::IMG_DOUBLE_HEIGHT,
|
||||
Escpos::IMG_DOUBLE_WIDTH | Escpos::IMG_DOUBLE_HEIGHT
|
||||
);
|
||||
foreach($imgModes as $mode) {
|
||||
$printer -> bitImage($logo, $mode);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
/* Images not supported on your PHP, or image file not found */
|
||||
$printer -> text($e -> getMessage() . "\n");
|
||||
}
|
||||
$printer -> cut();
|
||||
|
||||
/* QR Code - see also the more in-depth demo at qr-code.php */
|
||||
$testStr = "Testing 123";
|
||||
$models = array(
|
||||
Escpos::QR_MODEL_1 => "QR Model 1",
|
||||
Escpos::QR_MODEL_2 => "QR Model 2 (default)",
|
||||
Escpos::QR_MICRO => "Micro QR code\n(not supported on all printers)");
|
||||
foreach($models as $model => $name) {
|
||||
$printer -> qrCode($testStr, Escpos::QR_ECLEVEL_L, 3, $model);
|
||||
$printer -> text("$name\n");
|
||||
$printer -> feed();
|
||||
}
|
||||
$printer -> cut();
|
||||
|
||||
/* Pulse */
|
||||
$printer -> pulse();
|
||||
|
||||
/* Always close the printer! On some PrintConnectors, no actual
|
||||
* data is sent until the printer is closed. */
|
||||
$printer -> close();
|
||||
?>
|
||||
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/* Print-outs using the newer graphics print command */
|
||||
|
||||
require_once(dirname(__FILE__) . "/../Escpos.php");
|
||||
$printer = new Escpos();
|
||||
|
||||
try {
|
||||
$tux = new EscposImage("resources/tux.png");
|
||||
|
||||
$printer -> graphics($tux);
|
||||
$printer -> text("Regular Tux.\n");
|
||||
$printer -> feed();
|
||||
|
||||
$printer -> graphics($tux, Escpos::IMG_DOUBLE_WIDTH);
|
||||
$printer -> text("Wide Tux.\n");
|
||||
$printer -> feed();
|
||||
|
||||
$printer -> graphics($tux, Escpos::IMG_DOUBLE_HEIGHT);
|
||||
$printer -> text("Tall Tux.\n");
|
||||
$printer -> feed();
|
||||
|
||||
$printer -> graphics($tux, Escpos::IMG_DOUBLE_WIDTH | Escpos::IMG_DOUBLE_HEIGHT);
|
||||
$printer -> text("Large Tux in correct proportion.\n");
|
||||
|
||||
$printer -> cut();
|
||||
} catch(Exception $e) {
|
||||
/* Images not supported on your PHP, or image file not found */
|
||||
$printer -> text($e -> getMessage() . "\n");
|
||||
}
|
||||
|
||||
$printer -> close();
|
||||
?>
|
||||
@ -1,8 +0,0 @@
|
||||
Interfaces
|
||||
----------
|
||||
This directory contains boilerpalte code to show you how to open a print connector
|
||||
to printers which are connected in different ways.
|
||||
|
||||
To get a list of supported interfaces and operating systems, see the main README.md file for the project.
|
||||
|
||||
If you have a printer interface with no example, and you want to help put one together, then please lodge a request on the bug tracker: https://github.com/mike42/escpos-php/issues
|
||||
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
/* Change to the correct path if you copy this example! */
|
||||
require_once(dirname(__FILE__) . "/../../Escpos.php");
|
||||
|
||||
/* Most printers are open on port 9100, so you just need to know the IP
|
||||
* address of your receipt printer, and then fsockopen() it on that port.
|
||||
*/
|
||||
try {
|
||||
$connector = null;
|
||||
//$connector = new NetworkPrintConnector("10.x.x.x", 9100);
|
||||
|
||||
/* Print a "Hello world" receipt" */
|
||||
$printer = new Escpos($connector);
|
||||
$printer -> text("Hello World!\n");
|
||||
$printer -> cut();
|
||||
|
||||
/* Close printer */
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
|
||||
}
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
/* Change to the correct path if you copy this example! */
|
||||
require_once(dirname(__FILE__) . "/../../Escpos.php");
|
||||
|
||||
/**
|
||||
* On Linux, use the usblp module to make your printer available as a device
|
||||
* file. This is generally the default behaviour if you don't install any
|
||||
* vendor drivers.
|
||||
*
|
||||
* Once this is done, use a FilePrintConnector to open the device.
|
||||
*
|
||||
* Troubleshooting: On Debian, you must be in the lp group to access this file.
|
||||
* dmesg to see what happens when you plug in your printer to make sure no
|
||||
* other drivers are unloading the module.
|
||||
*/
|
||||
try {
|
||||
// Enter the device file for your USB printer here
|
||||
$connector = null;
|
||||
//$connector = new FilePrintConnector("/dev/usb/lp0");
|
||||
//$connector = new FilePrintConnector("/dev/usb/lp1");
|
||||
//$connector = new FilePrintConnector("/dev/usb/lp2");
|
||||
|
||||
/* Print a "Hello world" receipt" */
|
||||
$printer = new Escpos($connector);
|
||||
$printer -> text("Hello World!\n");
|
||||
$printer -> cut();
|
||||
|
||||
/* Close printer */
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
|
||||
}
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
/* Change to the correct path if you copy this example! */
|
||||
require_once(dirname(__FILE__) . "/../../Escpos.php");
|
||||
|
||||
/**
|
||||
* Install the printer using USB printing support, and the "Generic / Text Only" driver,
|
||||
* then share it.
|
||||
*
|
||||
* Use a WindowsPrintConnector with the share name to print. This works on either
|
||||
* Windows or Linux.
|
||||
*
|
||||
* Troubleshooting: Fire up a command prompt/terminal, and ensure that (if your printer is
|
||||
* shared as "Receipt Printer"), the following commands work.
|
||||
*
|
||||
* Windows: (use an appropriate "net use" command if you need authentication)
|
||||
* echo "Hello World" > testfile
|
||||
* ## If you need authentication, use "net use" to hook up the printer:
|
||||
* # net use "\\computername\Receipt Printer" /user:Guest
|
||||
* # net use "\\computername\Receipt Printer" /user:Bob secret
|
||||
* # net use "\\computername\Receipt Printer" /user:workgroup\Bob secret
|
||||
* copy testfile "\\computername\Receipt Printer"
|
||||
* del testfile
|
||||
*
|
||||
* GNU/Linux:
|
||||
* # No authentication
|
||||
* echo "Hello World" | smbclient "//computername/Receipt Printer" -c "print -" -N
|
||||
* # Guest login
|
||||
* echo "Hello World" | smbclient "//computername/Receipt Printer" -U Guest -c "print -" -N
|
||||
* # Basic username/password
|
||||
* echo "Hello World" | smbclient "//computername/Receipt Printer" secret -U "Bob" -c "print -"
|
||||
* # Including domain name
|
||||
* echo "Hello World" | smbclient "//computername/Receipt Printer" secret -U "workgroup\\Bob" -c "print -"
|
||||
*/
|
||||
try {
|
||||
// Enter the share name for your printer here, as a smb:// url format
|
||||
$connector = null;
|
||||
//$connector = new WindowsPrintConnector("smb://computername/Receipt Printer");
|
||||
//$connector = new WindowsPrintConnector("smb://Guest@computername/Receipt Printer");
|
||||
//$connector = new WindowsPrintConnector("smb://FooUser:secret@computername/workgroup/Receipt Printer");
|
||||
//$connector = new WindowsPrintConnector("smb://User:secret@computername/Receipt Printer");
|
||||
|
||||
/* Print a "Hello world" receipt" */
|
||||
$printer = new Escpos($connector);
|
||||
$printer -> text("Hello World!\n");
|
||||
$printer -> cut();
|
||||
|
||||
/* Close printer */
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
/* Change to the correct path if you copy this example! */
|
||||
require_once(dirname(__FILE__) . "/../../Escpos.php");
|
||||
|
||||
/**
|
||||
* Assuming your printer is available at LPT1,
|
||||
* simpy instantiate a WindowsPrintConnector to it.
|
||||
*
|
||||
* When troubleshooting, make sure you can send it
|
||||
* data from the command-line first:
|
||||
* echo "Hello World" > LPT1
|
||||
*/
|
||||
try {
|
||||
$connector = null;
|
||||
//$connector = new WindowsPrintConnector("LPT1");
|
||||
|
||||
// A FilePrintConnector will also work, but on non-Windows systems, writes
|
||||
// to an actual file called 'LPT1' rather than giving a useful error.
|
||||
// $connector = new FilePrintConnector("LPT1");
|
||||
|
||||
/* Print a "Hello world" receipt" */
|
||||
$printer = new Escpos($connector);
|
||||
$printer -> text("Hello World!\n");
|
||||
$printer -> cut();
|
||||
|
||||
/* Close printer */
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/* Change to the correct path if you copy this example! */
|
||||
require_once(dirname(__FILE__) . "/../../Escpos.php");
|
||||
|
||||
/**
|
||||
* Install the printer using USB printing support, and the "Generic / Text Only" driver,
|
||||
* then share it (you can use a firewall so that it can only be seen locally).
|
||||
*
|
||||
* Use a WindowsPrintConnector with the share name to print.
|
||||
*
|
||||
* Troubleshooting: Fire up a command prompt, and ensure that (if your printer is shared as
|
||||
* "Receipt Printer), the following commands work:
|
||||
*
|
||||
* echo "Hello World" > testfile
|
||||
* copy testfile "\\%COMPUTERNAME%\Receipt Printer"
|
||||
* del testfile
|
||||
*/
|
||||
try {
|
||||
// Enter the share name for your USB printer here
|
||||
$connector = null;
|
||||
//$connector = new WindowsPrintConnector("Receipt Printer");
|
||||
|
||||
/* Print a "Hello world" receipt" */
|
||||
$printer = new Escpos($connector);
|
||||
$printer -> text("Hello World!\n");
|
||||
$printer -> cut();
|
||||
|
||||
/* Close printer */
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/../Escpos.php");
|
||||
/*
|
||||
* Due to its complxity, escpos-php does not support HTML input. To print HTML,
|
||||
* either convert it to calls on the Escpos() object, or rasterise the page with
|
||||
* wkhtmltopdf, an external package which is designed to handle HTML efficiently.
|
||||
*
|
||||
* This example is provided to get you started.
|
||||
*
|
||||
* Note: Depending on the height of your pages, it is suggested that you chop it
|
||||
* into smaller sections, as printers simply don't have the buffer capacity for
|
||||
* very large images.
|
||||
*
|
||||
* As always, you can trade off quality for capacity by halving the width
|
||||
* (550 -> 225 below) and printing w/ Escpos::IMG_DOUBLE_WIDTH | Escpos::IMG_DOUBLE_HEIGHT
|
||||
*/
|
||||
try {
|
||||
/* Set up command */
|
||||
$source = "http://en.m.wikipedia.org/wiki/ESC/P";
|
||||
$width = 550;
|
||||
$dest = tempnam(sys_get_temp_dir(), 'escpos') . ".png";
|
||||
$cmd = sprintf("wkhtmltoimage -n -q --width %s %s %s",
|
||||
escapeshellarg($width),
|
||||
escapeshellarg($source),
|
||||
escapeshellarg($dest));
|
||||
|
||||
/* Run wkhtmltoimage */
|
||||
ob_start();
|
||||
system($cmd); // Can also use popen() for better control of process
|
||||
$outp = ob_get_contents();
|
||||
ob_end_clean();
|
||||
if(!file_exists($dest)) {
|
||||
throw new Exception("Command $cmd failed: $outp");
|
||||
}
|
||||
|
||||
/* Load up the image */
|
||||
try {
|
||||
$img = new EscposImage($dest);
|
||||
} catch(Exception $e) {
|
||||
unlink($dest);
|
||||
throw $e;
|
||||
}
|
||||
unlink($dest);
|
||||
|
||||
/* Print it */
|
||||
$printer = new Escpos(); // Add connector for your printer here.
|
||||
$printer -> bitImage($img); // bitImage() seems to allow larger images than graphics() on the TM-T20.
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
echo $e -> getMessage();
|
||||
}
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/../Escpos.php');
|
||||
/*
|
||||
* This is three examples in one:
|
||||
* 1: Print an entire PDF, normal quality.
|
||||
* 2: Print at a lower quality for speed increase (CPU & transfer)
|
||||
* 3: Cache rendered documents for a speed increase (removes CPU image processing completely on subsequent prints)
|
||||
*/
|
||||
|
||||
/* 1: Print an entire PDF, start-to-finish (shorter form of the example) */
|
||||
$pdf = 'resources/document.pdf';
|
||||
try {
|
||||
$pages = EscposImage::loadPdf($pdf);
|
||||
$printer = new Escpos();
|
||||
foreach($pages as $page) {
|
||||
$printer -> graphics($page);
|
||||
}
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
} catch(Exception $e) {
|
||||
/*
|
||||
* loadPdf() throws exceptions if files or not found, or you don't have the
|
||||
* imagick extension to read PDF's
|
||||
*/
|
||||
echo $e -> getMessage() . "\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 2: Speed up printing by roughly halving the resolution, and printing double-size.
|
||||
* This gives a 75% speed increase at the expense of some quality.
|
||||
*
|
||||
* Reduce the page width further if necessary: if it extends past the printing area, your prints will be very slow.
|
||||
*/
|
||||
$printer = new Escpos();
|
||||
$pdf = 'resources/document.pdf';
|
||||
$pages = EscposImage::loadPdf($pdf, 260);
|
||||
foreach($pages as $page) {
|
||||
$printer -> graphics($page, Escpos::IMG_DOUBLE_HEIGHT | Escpos::IMG_DOUBLE_WIDTH);
|
||||
}
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
|
||||
/*
|
||||
* 3: PDF printing still too slow? If you regularly print the same files, serialize & compress your
|
||||
* EscposImage objects (after printing[1]), instead of throwing them away.
|
||||
*
|
||||
* (You can also do this to print logos on computers which don't have an
|
||||
* image processing library, by preparing a serialized version of your logo on your PC)
|
||||
*
|
||||
* [1]After printing, the pixels are loaded and formatted for the print command you used, so even a raspberry pi can print complex PDF's quickly.
|
||||
*/
|
||||
$printer = new Escpos();
|
||||
$pdf = 'resources/document.pdf';
|
||||
$ser = 'resources/document.z';
|
||||
if(!file_exists($ser)) {
|
||||
$pages = EscposImage::loadPdf($pdf);
|
||||
} else {
|
||||
$pages = unserialize(gzuncompress(file_get_contents($ser)));
|
||||
}
|
||||
|
||||
foreach($pages as $page) {
|
||||
$printer -> graphics($page);
|
||||
}
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
|
||||
if(!file_exists($ser)) {
|
||||
file_put_contents($ser, gzcompress(serialize($pages)));
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
/* Demonstration of available options on the qrCode() command */
|
||||
require_once(dirname(__FILE__) . "/../Escpos.php");
|
||||
$printer = new Escpos();
|
||||
|
||||
// Most simple example
|
||||
title($printer, "QR code demo\n");
|
||||
$testStr = "Testing 123";
|
||||
$printer -> qrCode($testStr);
|
||||
$printer -> text("Most simple example\n");
|
||||
$printer -> feed();
|
||||
|
||||
// Demo that alignment is the same as text
|
||||
$printer -> setJustification(Escpos::JUSTIFY_CENTER);
|
||||
$printer -> qrCode($testStr);
|
||||
$printer -> text("Same example, centred\n");
|
||||
$printer -> setJustification();
|
||||
$printer -> feed();
|
||||
|
||||
// Demo of numeric data being packed more densly
|
||||
title($printer, "Data encoding\n");
|
||||
$test = array(
|
||||
"Numeric" => "0123456789012345678901234567890123456789",
|
||||
"Alphanumeric" => "abcdefghijklmnopqrstuvwxyzabcdefghijklmn",
|
||||
"Binary" => str_repeat("\0", 40));
|
||||
foreach($test as $type => $data) {
|
||||
$printer -> qrCode($data);
|
||||
$printer -> text("$type\n");
|
||||
$printer -> feed();
|
||||
}
|
||||
|
||||
// Demo of error correction
|
||||
title($printer, "Error correction\n");
|
||||
$ec = array(
|
||||
Escpos::QR_ECLEVEL_L => "L",
|
||||
Escpos::QR_ECLEVEL_M => "M",
|
||||
Escpos::QR_ECLEVEL_Q => "Q",
|
||||
Escpos::QR_ECLEVEL_H => "H");
|
||||
foreach($ec as $level => $name) {
|
||||
$printer -> qrCode($testStr, $level);
|
||||
$printer -> text("Error correction $name\n");
|
||||
$printer -> feed();
|
||||
}
|
||||
|
||||
// Change size
|
||||
title($printer, "Pixel size\n");
|
||||
$sizes = array(
|
||||
1 => "(minimum)",
|
||||
2 => "",
|
||||
3 => "(default)",
|
||||
4 => "",
|
||||
5 => "",
|
||||
10 => "",
|
||||
16 => "(maximum)");
|
||||
foreach($sizes as $size => $label) {
|
||||
$printer -> qrCode($testStr, Escpos::QR_ECLEVEL_L, $size);
|
||||
$printer -> text("Pixel size $size $label\n");
|
||||
$printer -> feed();
|
||||
}
|
||||
|
||||
// Change model
|
||||
title($printer, "QR model\n");
|
||||
$models = array(
|
||||
Escpos::QR_MODEL_1 => "QR Model 1",
|
||||
Escpos::QR_MODEL_2 => "QR Model 2 (default)",
|
||||
Escpos::QR_MICRO => "Micro QR code\n(not supported on all printers)");
|
||||
foreach($models as $model => $name) {
|
||||
$printer -> qrCode($testStr, Escpos::QR_ECLEVEL_L, 3, $model);
|
||||
$printer -> text("$name\n");
|
||||
$printer -> feed();
|
||||
}
|
||||
|
||||
// Cut & close
|
||||
$printer -> cut();
|
||||
$printer -> close();
|
||||
|
||||
function title(Escpos $printer, $str) {
|
||||
$printer -> selectPrintMode(Escpos::MODE_DOUBLE_HEIGHT | Escpos::MODE_DOUBLE_WIDTH);
|
||||
$printer -> text($str);
|
||||
$printer -> selectPrintMode();
|
||||
}
|
||||
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/../Escpos.php");
|
||||
|
||||
/* Information for the receipt */
|
||||
$items = array(
|
||||
new item("Example item #1", "4.00"),
|
||||
new item("Another thing", "3.50"),
|
||||
new item("Something else", "1.00"),
|
||||
new item("A final item", "4.45"),
|
||||
);
|
||||
$subtotal = new item('Subtotal', '12.95');
|
||||
$tax = new item('A local tax', '1.30');
|
||||
$total = new item('Total', '14.25', true);
|
||||
/* Date is kept the same for testing */
|
||||
// $date = date('l jS \of F Y h:i:s A');
|
||||
$date = "Monday 6th of April 2015 02:56:25 PM";
|
||||
|
||||
/* Start the printer */
|
||||
$logo = new EscposImage("resources/escpos-php.png");
|
||||
$printer = new Escpos();
|
||||
|
||||
/* Print top logo */
|
||||
$printer -> setJustification(Escpos::JUSTIFY_CENTER);
|
||||
$printer -> graphics($logo);
|
||||
|
||||
/* Name of shop */
|
||||
$printer -> selectPrintMode(Escpos::MODE_DOUBLE_WIDTH);
|
||||
$printer -> text("ExampleMart Ltd.\n");
|
||||
$printer -> selectPrintMode();
|
||||
$printer -> text("Shop No. 42.\n");
|
||||
$printer -> feed();
|
||||
|
||||
/* Title of receipt */
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> text("SALES INVOICE\n");
|
||||
$printer -> setEmphasis(false);
|
||||
|
||||
/* Items */
|
||||
$printer -> setJustification(Escpos::JUSTIFY_LEFT);
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> text(new item('', '$'));
|
||||
$printer -> setEmphasis(false);
|
||||
foreach($items as $item) {
|
||||
$printer -> text($item);
|
||||
}
|
||||
$printer -> setEmphasis(true);
|
||||
$printer -> text($subtotal);
|
||||
$printer -> setEmphasis(false);
|
||||
$printer -> feed();
|
||||
|
||||
/* Tax and total */
|
||||
$printer -> text($tax);
|
||||
$printer -> selectPrintMode(Escpos::MODE_DOUBLE_WIDTH);
|
||||
$printer -> text($total);
|
||||
$printer -> selectPrintMode();
|
||||
|
||||
/* Footer */
|
||||
$printer -> feed(2);
|
||||
$printer -> setJustification(Escpos::JUSTIFY_CENTER);
|
||||
$printer -> text("Thank you for shopping at ExampleMart\n");
|
||||
$printer -> text("For trading hours, please visit example.com\n");
|
||||
$printer -> feed(2);
|
||||
$printer -> text($date . "\n");
|
||||
|
||||
/* Cut the receipt and open the cash drawer */
|
||||
$printer -> cut();
|
||||
$printer -> pulse();
|
||||
|
||||
$printer -> close();
|
||||
|
||||
/* A wrapper to do organise item names & prices into columns */
|
||||
class item {
|
||||
private $name;
|
||||
private $price;
|
||||
private $dollarSign;
|
||||
|
||||
public function __construct($name = '', $price = '', $dollarSign = false) {
|
||||
$this -> name = $name;
|
||||
$this -> price = $price;
|
||||
$this -> dollarSign = $dollarSign;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
$rightCols = 10;
|
||||
$leftCols = 38;
|
||||
if($this -> dollarSign) {
|
||||
$leftCols = $leftCols / 2 - $rightCols / 2;
|
||||
}
|
||||
$left = str_pad($this -> name, $leftCols) ;
|
||||
|
||||
$sign = ($this -> dollarSign ? '$ ' : '');
|
||||
$right = str_pad($sign . $this -> price, $rightCols, ' ', STR_PAD_LEFT);
|
||||
return "$left$right\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user