Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop Conflicts: htdocs/comm/action/class/actioncomm.class.php htdocs/compta/facture/class/facture.class.php htdocs/core/class/html.form.class.php
This commit is contained in:
commit
ab50437331
12
.tx/config
12
.tx/config
@ -236,6 +236,18 @@ source_file = htdocs/langs/en_US/paypal.lang
|
|||||||
source_lang = en_US
|
source_lang = en_US
|
||||||
type = MOZILLAPROPERTIES
|
type = MOZILLAPROPERTIES
|
||||||
|
|
||||||
|
[dolibarr.printgcp]
|
||||||
|
file_filter = htdocs/langs/<lang>/printgcp.lang
|
||||||
|
source_file = htdocs/langs/en_US/printgcp.lang
|
||||||
|
source_lang = en_US
|
||||||
|
type = MOZILLAPROPERTIES
|
||||||
|
|
||||||
|
[dolibarr.printing]
|
||||||
|
file_filter = htdocs/langs/<lang>/printing.lang
|
||||||
|
source_file = htdocs/langs/en_US/printing.lang
|
||||||
|
source_lang = en_US
|
||||||
|
type = MOZILLAPROPERTIES
|
||||||
|
|
||||||
[dolibarr.printipp]
|
[dolibarr.printipp]
|
||||||
file_filter = htdocs/langs/<lang>/printipp.lang
|
file_filter = htdocs/langs/<lang>/printipp.lang
|
||||||
source_file = htdocs/langs/en_US/printipp.lang
|
source_file = htdocs/langs/en_US/printipp.lang
|
||||||
|
|||||||
@ -52,6 +52,9 @@ http://www.fsf.org/licensing/licenses/index_html
|
|||||||
Copyright
|
Copyright
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
Copyright (C) 2015
|
||||||
|
- Marcos García <marcosgdf@gmail.com>
|
||||||
|
|
||||||
Copyright (C) 2014
|
Copyright (C) 2014
|
||||||
- Laurent Destailleur <eldy@users.sourceforge.net>
|
- Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
- Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
- Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
|
|||||||
14
ChangeLog
14
ChangeLog
@ -196,6 +196,18 @@ Dolibarr better:
|
|||||||
- Fix: ref_ext was not saved when recording a customer order from web service
|
- Fix: ref_ext was not saved when recording a customer order from web service
|
||||||
- Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid.
|
- Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid.
|
||||||
- Fix: withdrawal create error if in the same month are deleted previus withdrawals.
|
- Fix: withdrawal create error if in the same month are deleted previus withdrawals.
|
||||||
|
- Fix: [ bug #1788 ] Duplicated doActions hook in product/fournisseurs.php
|
||||||
|
- Fix: withdrawal create error if in the same month are deleted previus withdrawals.
|
||||||
|
- Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules
|
||||||
|
- Fix: [ bug #1802 ] SQL error when updating a task with PostgreSQL database
|
||||||
|
- Fix: [ bug #1785 ] Start date is lost in Project > Linked objects
|
||||||
|
- Fix: [ bug #1804 ] SQL error when sending email without addresee
|
||||||
|
- Fix: [ bug #1803 ] AJAX company contact input is not aligned
|
||||||
|
- Fix: [ bug #1787 ] Incorrect behaviour of doActions hook
|
||||||
|
- Fix: [ bug #1796 ] Unable to use numeration modules from an external module
|
||||||
|
- Fix: [ bug #1783 ] SQL error when enabling 3rd party module with PostgreSQL and MySQL strict mode ON
|
||||||
|
- Fix: [ bug #1717 ] Sorting unpaid invoices by amount received brings due amount
|
||||||
|
- Fix: [ bug #1784 ] MOTD doesn't show up in Amarok theme
|
||||||
|
|
||||||
***** ChangeLog for 3.6.2 compared to 3.6.1 *****
|
***** ChangeLog for 3.6.2 compared to 3.6.1 *****
|
||||||
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.
|
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.
|
||||||
@ -360,6 +372,8 @@ Fix: Paypal link were broken dur to SSL v3 closed.
|
|||||||
Fix: [ bug #1769 ] Error when installing to a PostgreSQL DB that contains numbers
|
Fix: [ bug #1769 ] Error when installing to a PostgreSQL DB that contains numbers
|
||||||
Fix: [ bug #1752 ] Date filter of margins module, filters since 12H instead of 00H
|
Fix: [ bug #1752 ] Date filter of margins module, filters since 12H instead of 00H
|
||||||
Fix: [ bug #1757 ] Sorting breaks product/service statistics
|
Fix: [ bug #1757 ] Sorting breaks product/service statistics
|
||||||
|
Fix: [ bug #1797 ] Tulip supplier invoice module takes creation date instead of invoice date
|
||||||
|
Fix: [ bug #1792 ] Users are not allowed to see margins module index page when no product view permission is enabled
|
||||||
|
|
||||||
***** ChangeLog for 3.5.6 compared to 3.5.5 *****
|
***** ChangeLog for 3.5.6 compared to 3.5.5 *****
|
||||||
Fix: Avoid missing class error for fetch_thirdparty method #1973
|
Fix: Avoid missing class error for fetch_thirdparty method #1973
|
||||||
|
|||||||
@ -11,7 +11,6 @@ beta version of Dolibarr, step by step.
|
|||||||
- Update version/info in /ChangeLog
|
- Update version/info in /ChangeLog
|
||||||
- Update version number with x.y.z-w in htdocs/filefunc.inc.php
|
- Update version number with x.y.z-w in htdocs/filefunc.inc.php
|
||||||
- Update version number with x.y.z-w in build/debian/changelog
|
- Update version number with x.y.z-w in build/debian/changelog
|
||||||
- Update version number with x.y.z-w in build/exe/doliwamp/doliwamp.iss
|
|
||||||
- Update version number with x.y.z-w in build/rpm/*.spec
|
- Update version number with x.y.z-w in build/rpm/*.spec
|
||||||
- Commit all changes.
|
- Commit all changes.
|
||||||
- Add a Tag (x.y.betaz_YYYYMMDD) and push it: git push --tags
|
- Add a Tag (x.y.betaz_YYYYMMDD) and push it: git push --tags
|
||||||
@ -30,10 +29,9 @@ This files describe steps made by Dolibarr packaging team to make a
|
|||||||
complete release of Dolibarr, step by step.
|
complete release of Dolibarr, step by step.
|
||||||
|
|
||||||
- Check all files are commited.
|
- Check all files are commited.
|
||||||
- Update version/info in ChangeLog
|
- Update version/info in ChangeLog. To generate a changelog, you can do "git log x.y.z..HEAD --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^Fix\|New\|Sec'"
|
||||||
- Update version number with x.y.z in htdocs/filefunc.inc.php
|
- Update version number with x.y.z in htdocs/filefunc.inc.php
|
||||||
- Update version number with x.y.z in build/debian/changelog
|
- Update version number with x.y.z in build/debian/changelog
|
||||||
- Update version number with x.y.z in build/exe/doliwamp/doliwamp.iss
|
|
||||||
- Update version number with x.y.z in build/rpm/*.spec
|
- Update version number with x.y.z in build/rpm/*.spec
|
||||||
- Commit all changes.
|
- Commit all changes.
|
||||||
|
|
||||||
|
|||||||
@ -119,6 +119,8 @@ $parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas);
|
|||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
|
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
@ -682,7 +684,7 @@ if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -65,12 +65,12 @@ if ($action == 'update' && empty($_POST["cancel"]))
|
|||||||
{
|
{
|
||||||
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity);
|
||||||
// Send mode parameters
|
// Send mode parameters
|
||||||
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',0);
|
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity);
|
||||||
if (isset($_POST["MAIN_MAIL_SMTP_PORT"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',0);
|
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity);
|
||||||
if (isset($_POST["MAIN_MAIL_SMTP_SERVER"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',0);
|
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',$conf->entity);
|
||||||
if (isset($_POST["MAIN_MAIL_SMTPS_ID"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',0);
|
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',$conf->entity);
|
||||||
if (isset($_POST["MAIN_MAIL_SMTPS_PW"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',0);
|
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',$conf->entity);
|
||||||
if (isset($_POST["MAIN_MAIL_EMAIL_TLS"])) dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',0);
|
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',$conf->entity);
|
||||||
// Content parameters
|
// Content parameters
|
||||||
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity);
|
||||||
dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity);
|
||||||
|
|||||||
@ -118,6 +118,13 @@ class ActionComm extends CommonObject
|
|||||||
$error=0;
|
$error=0;
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (empty($this->userownerid))
|
||||||
|
{
|
||||||
|
$this->errors[]='ErrorPropertyUserowneridNotDefined';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->label=dol_trunc(trim($this->label),128);
|
$this->label=dol_trunc(trim($this->label),128);
|
||||||
$this->location=dol_trunc(trim($this->location),128);
|
$this->location=dol_trunc(trim($this->location),128);
|
||||||
@ -147,8 +154,9 @@ class ActionComm extends CommonObject
|
|||||||
$userownerid=$this->userownerid;
|
$userownerid=$this->userownerid;
|
||||||
$userdoneid=$this->userdoneid;
|
$userdoneid=$this->userdoneid;
|
||||||
|
|
||||||
// Be sure assigned user array is not empty.
|
// Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...).
|
||||||
if (count($this->userassigned) == 0) $this->userassigned[] = array('id'=>$userownerid);
|
if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned))
|
||||||
|
$this->userassigned = array($userownerid=>array('id'=>$userownerid));
|
||||||
|
|
||||||
if (! $this->type_id || ! $this->type_code)
|
if (! $this->type_id || ! $this->type_code)
|
||||||
{
|
{
|
||||||
@ -235,6 +243,12 @@ class ActionComm extends CommonObject
|
|||||||
{
|
{
|
||||||
foreach($this->userassigned as $key => $val)
|
foreach($this->userassigned as $key => $val)
|
||||||
{
|
{
|
||||||
|
if (! is_array($val)) // For backward compatibility when valid
|
||||||
|
{
|
||||||
|
$tmpid=$val;
|
||||||
|
$val=array('id'=>$val);
|
||||||
|
}
|
||||||
|
|
||||||
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
|
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
|
||||||
$sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".($val['mandatory']?$val['mandatory']:'0').", ".($val['transparency']?$val['transparency']:'0').", ".($val['answer_status']?$val['answer_status']:'0').")";
|
$sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".($val['mandatory']?$val['mandatory']:'0').", ".($val['transparency']?$val['transparency']:'0').", ".($val['answer_status']?$val['answer_status']:'0').")";
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,7 @@ $pageprev = $page - 1;
|
|||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (! $sortorder) $sortorder="ASC";
|
if (! $sortorder) $sortorder="ASC";
|
||||||
if (! $sortfield) $sortfield="nom";
|
if (! $sortfield) $sortfield="nom";
|
||||||
|
$cancelbutton = GETPOST('cancel');
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
$hookmanager->initHooks(array('commcard','globalcard'));
|
$hookmanager->initHooks(array('commcard','globalcard'));
|
||||||
@ -80,12 +81,14 @@ $parameters = array('socid' => $id);
|
|||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
//Some actions show a "cancel" input submit button with name="cancel"
|
if (empty($reshook))
|
||||||
$cancelbutton = GETPOST('cancel');
|
{
|
||||||
|
if ($cancelbutton)
|
||||||
|
{
|
||||||
|
$action="";
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'setcustomeraccountancycode')
|
if ($action == 'setcustomeraccountancycode')
|
||||||
{
|
|
||||||
if (! $cancelbutton)
|
|
||||||
{
|
{
|
||||||
$result=$object->fetch($id);
|
$result=$object->fetch($id);
|
||||||
$object->code_compta=$_POST["customeraccountancycode"];
|
$object->code_compta=$_POST["customeraccountancycode"];
|
||||||
@ -95,8 +98,6 @@ if ($action == 'setcustomeraccountancycode')
|
|||||||
setEventMessage($object->errors, 'errors');
|
setEventMessage($object->errors, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$action="";
|
|
||||||
}
|
|
||||||
|
|
||||||
// conditions de reglement
|
// conditions de reglement
|
||||||
if ($action == 'setconditions' && $user->rights->societe->creer)
|
if ($action == 'setconditions' && $user->rights->societe->creer)
|
||||||
@ -143,8 +144,6 @@ if ($action == 'cstc')
|
|||||||
|
|
||||||
// update outstandng limit
|
// update outstandng limit
|
||||||
if ($action == 'setOutstandingBill')
|
if ($action == 'setOutstandingBill')
|
||||||
{
|
|
||||||
if (!$cancelbutton)
|
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->outstanding_limit=GETPOST('OutstandingBill');
|
$object->outstanding_limit=GETPOST('OutstandingBill');
|
||||||
|
|||||||
@ -110,6 +110,8 @@ $parameters=array();
|
|||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
// Action clone object
|
// Action clone object
|
||||||
if ($action == 'confirm_clone' && $confirm == 'yes')
|
if ($action == 'confirm_clone' && $confirm == 'yes')
|
||||||
{
|
{
|
||||||
@ -649,20 +651,19 @@ if (! empty($_POST["cancel"]))
|
|||||||
{
|
{
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
$htmlother = new FormOther($db);
|
||||||
|
|
||||||
$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
|
$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
|
||||||
llxHeader('',$langs->trans("Mailing"),$help_url);
|
llxHeader('',$langs->trans("Mailing"),$help_url);
|
||||||
|
|
||||||
$form = new Form($db);
|
|
||||||
$htmlother = new FormOther($db);
|
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
// EMailing in creation mode
|
// EMailing in creation mode
|
||||||
|
|||||||
@ -108,6 +108,8 @@ $parameters = array('socid' => $socid);
|
|||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
||||||
|
|
||||||
// Action clone object
|
// Action clone object
|
||||||
@ -550,7 +552,33 @@ else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_printipp.inc.php';
|
// Classify billed
|
||||||
|
else if ($action == 'classifybilled' && $user->rights->propal->cloturer) {
|
||||||
|
$object->cloture($user, 4, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reopen proposal
|
||||||
|
else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) {
|
||||||
|
// prevent browser refresh from reopening proposal several times
|
||||||
|
if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) {
|
||||||
|
$object->reopen($user, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close proposal
|
||||||
|
else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) {
|
||||||
|
if (! GETPOST('statut')) {
|
||||||
|
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors');
|
||||||
|
$action = 'statut';
|
||||||
|
} else {
|
||||||
|
// prevent browser refresh from closing proposal several times
|
||||||
|
if ($object->statut == 1) {
|
||||||
|
$object->cloture($user, GETPOST('statut'), GETPOST('note'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1146,6 +1174,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -2550,21 +2550,18 @@ class Propal extends CommonObject
|
|||||||
{
|
{
|
||||||
$mybool=false;
|
$mybool=false;
|
||||||
|
|
||||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
|
||||||
foreach ($dirmodels as $reldir)
|
|
||||||
{
|
|
||||||
$file = $conf->global->PROPALE_ADDON.".php";
|
$file = $conf->global->PROPALE_ADDON.".php";
|
||||||
$classname = $conf->global->PROPALE_ADDON;
|
$classname = $conf->global->PROPALE_ADDON;
|
||||||
|
|
||||||
// Include file with class
|
// Include file with class
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
{
|
foreach ($dirmodels as $reldir) {
|
||||||
$dir = $dirroot.$reldir."/core/modules/propale/";
|
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/propale/");
|
||||||
|
|
||||||
// Load file with numbering class (if found)
|
// Load file with numbering class (if found)
|
||||||
$mybool|=@include_once $dir.$file;
|
$mybool|=@include_once $dir.$file;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (! $mybool)
|
if (! $mybool)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -177,12 +177,14 @@ $parameters=array();
|
|||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook)) {
|
||||||
if ($action == 'cstc')
|
if ($action == 'cstc')
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"];
|
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"];
|
||||||
$sql .= " WHERE rowid = ".$_GET["socid"];
|
$sql .= " WHERE rowid = ".$_GET["socid"];
|
||||||
$result=$db->query($sql);
|
$result=$db->query($sql);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -102,6 +102,8 @@ $parameters = array('socid' => $socid);
|
|||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
||||||
|
|
||||||
// Action clone object
|
// Action clone object
|
||||||
@ -1198,6 +1200,8 @@ if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->righ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
|
|||||||
@ -141,20 +141,19 @@ class Commande extends CommonOrder
|
|||||||
if (! empty($conf->global->COMMANDE_ADDON))
|
if (! empty($conf->global->COMMANDE_ADDON))
|
||||||
{
|
{
|
||||||
$mybool=false;
|
$mybool=false;
|
||||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
|
||||||
foreach ($dirmodels as $reldir)
|
|
||||||
{
|
|
||||||
$file = $conf->global->COMMANDE_ADDON.".php";
|
$file = $conf->global->COMMANDE_ADDON.".php";
|
||||||
$classname = $conf->global->COMMANDE_ADDON;
|
$classname = $conf->global->COMMANDE_ADDON;
|
||||||
|
|
||||||
// Include file with class
|
// Include file with class
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||||
|
foreach ($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
$dir = $dirroot.$reldir."/core/modules/commande/";
|
$dir = dol_buildpath($reldir."core/modules/commande/");
|
||||||
|
|
||||||
// Load file with numbering class (if found)
|
// Load file with numbering class (if found)
|
||||||
$mybool|=@include_once $dir.$file;
|
$mybool|=@include_once $dir.$file;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (! $mybool)
|
if (! $mybool)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -106,6 +106,7 @@ $hookmanager->initHooks(array('invoicecard','globalcard'));
|
|||||||
|
|
||||||
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
|
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
@ -114,6 +115,8 @@ $parameters = array('socid' => $socid);
|
|||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
||||||
|
|
||||||
// Action clone object
|
// Action clone object
|
||||||
@ -838,7 +841,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
$object->remise_absolue = $_POST['remise_absolue'];
|
$object->remise_absolue = $_POST['remise_absolue'];
|
||||||
$object->remise_percent = $_POST['remise_percent'];
|
$object->remise_percent = $_POST['remise_percent'];
|
||||||
|
|
||||||
if($_POST['type'] == Facture::TYPE_SITUATION) {
|
if (GETPOST('type') == Facture::TYPE_SITUATION)
|
||||||
|
{
|
||||||
$object->situation_counter = 1;
|
$object->situation_counter = 1;
|
||||||
$object->situation_final = 0;
|
$object->situation_final = 0;
|
||||||
$object->situation_cycle_ref = $object->newCycle();
|
$object->situation_cycle_ref = $object->newCycle();
|
||||||
@ -1097,7 +1101,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['type'] == Facture::TYPE_SITUATION && (!empty($_POST['situations']))) {
|
if (GETPOST('type') == Facture::TYPE_SITUATION && (!empty($_POST['situations'])))
|
||||||
|
{
|
||||||
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||||
if (empty($datefacture)) {
|
if (empty($datefacture)) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -1465,7 +1470,8 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
|||||||
$line->fetch(GETPOST('lineid'));
|
$line->fetch(GETPOST('lineid'));
|
||||||
$percent = $line->get_prev_progress();
|
$percent = $line->get_prev_progress();
|
||||||
|
|
||||||
if (GETPOST('progress') < $percent) {
|
if (GETPOST('progress') < $percent)
|
||||||
|
{
|
||||||
$mesg = '<div class="warning">' . $langs->trans("CantBeLessThanMinPercent") . '</div>';
|
$mesg = '<div class="warning">' . $langs->trans("CantBeLessThanMinPercent") . '</div>';
|
||||||
setEventMessages($mesg, null, 'warnings');
|
setEventMessages($mesg, null, 'warnings');
|
||||||
$error++;
|
$error++;
|
||||||
@ -1474,7 +1480,8 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
|||||||
|
|
||||||
// Check minimum price
|
// Check minimum price
|
||||||
$productid = GETPOST('productid', 'int');
|
$productid = GETPOST('productid', 'int');
|
||||||
if (! empty($productid)) {
|
if (! empty($productid))
|
||||||
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$product->fetch($productid);
|
$product->fetch($productid);
|
||||||
|
|
||||||
@ -1543,6 +1550,23 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
|||||||
unset($_POST['buying_price']);
|
unset($_POST['buying_price']);
|
||||||
unset($_POST['np_marginRate']);
|
unset($_POST['np_marginRate']);
|
||||||
unset($_POST['np_markRate']);
|
unset($_POST['np_markRate']);
|
||||||
|
|
||||||
|
unset($_POST['dp_desc']);
|
||||||
|
unset($_POST['idprod']);
|
||||||
|
|
||||||
|
unset($_POST['date_starthour']);
|
||||||
|
unset($_POST['date_startmin']);
|
||||||
|
unset($_POST['date_startsec']);
|
||||||
|
unset($_POST['date_startday']);
|
||||||
|
unset($_POST['date_startmonth']);
|
||||||
|
unset($_POST['date_startyear']);
|
||||||
|
unset($_POST['date_endhour']);
|
||||||
|
unset($_POST['date_endmin']);
|
||||||
|
unset($_POST['date_endsec']);
|
||||||
|
unset($_POST['date_endday']);
|
||||||
|
unset($_POST['date_endmonth']);
|
||||||
|
unset($_POST['date_endyear']);
|
||||||
|
|
||||||
unset($_POST['situations']);
|
unset($_POST['situations']);
|
||||||
unset($_POST['progress']);
|
unset($_POST['progress']);
|
||||||
} else {
|
} else {
|
||||||
@ -1551,10 +1575,13 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'updatealllines' && $user->rights->facture->creer && $_POST['all_percent'] == $langs->trans('Modifier')) {
|
else if ($action == 'updatealllines' && $user->rights->facture->creer && $_POST['all_percent'] == $langs->trans('Modifier'))
|
||||||
|
{
|
||||||
if (!$object->fetch($id) > 0) dol_print_error($db);
|
if (!$object->fetch($id) > 0) dol_print_error($db);
|
||||||
if (!is_null(GETPOST('all_progress')) && GETPOST('all_progress') != "") {
|
if (!is_null(GETPOST('all_progress')) && GETPOST('all_progress') != "")
|
||||||
foreach ($object->lines as $line) {
|
{
|
||||||
|
foreach ($object->lines as $line)
|
||||||
|
{
|
||||||
$percent = $line->get_prev_progress();
|
$percent = $line->get_prev_progress();
|
||||||
if (GETPOST('all_progress') < $percent) {
|
if (GETPOST('all_progress') < $percent) {
|
||||||
$mesg = '<div class="warning">' . $langs->trans("CantBeLessThanMinPercent") . '</div>';
|
$mesg = '<div class="warning">' . $langs->trans("CantBeLessThanMinPercent") . '</div>';
|
||||||
@ -1690,7 +1717,7 @@ else if ($action == 'remove_file') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_printipp.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
|
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
|
||||||
{
|
{
|
||||||
@ -1717,7 +1744,8 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture-
|
|||||||
}
|
}
|
||||||
|
|
||||||
// bascule du statut d'un contact
|
// bascule du statut d'un contact
|
||||||
else if ($action == 'swapstatut') {
|
else if ($action == 'swapstatut')
|
||||||
|
{
|
||||||
if ($object->fetch($id)) {
|
if ($object->fetch($id)) {
|
||||||
$result = $object->swapContactStatus(GETPOST('ligne'));
|
$result = $object->swapContactStatus(GETPOST('ligne'));
|
||||||
} else {
|
} else {
|
||||||
@ -1726,7 +1754,8 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture-
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Efface un contact
|
// Efface un contact
|
||||||
else if ($action == 'deletecontact') {
|
else if ($action == 'deletecontact')
|
||||||
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$result = $object->delete_contact($lineid);
|
$result = $object->delete_contact($lineid);
|
||||||
|
|
||||||
@ -1737,9 +1766,10 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture-
|
|||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'update_extras') {
|
|
||||||
|
if ($action == 'update_extras')
|
||||||
|
{
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
||||||
@ -1765,7 +1795,8 @@ if ($action == 'update_extras') {
|
|||||||
if ($error)
|
if ($error)
|
||||||
$action = 'edit_extras';
|
$action = 'edit_extras';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2037,6 +2068,8 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($socid > 0)
|
if ($socid > 0)
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->INVOICE_USE_SITUATION))
|
||||||
{
|
{
|
||||||
// First situation invoice
|
// First situation invoice
|
||||||
print '<tr height="18"><td width="16px" valign="middle">';
|
print '<tr height="18"><td width="16px" valign="middle">';
|
||||||
@ -2060,6 +2093,7 @@ if ($action == 'create')
|
|||||||
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1);
|
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1);
|
||||||
print $desc;
|
print $desc;
|
||||||
print '</td></tr>' . "\n";
|
print '</td></tr>' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Replacement
|
// Replacement
|
||||||
print '<tr height="18"><td valign="middle">';
|
print '<tr height="18"><td valign="middle">';
|
||||||
@ -2372,7 +2406,7 @@ if ($action == 'create')
|
|||||||
// Button "Create Draft"
|
// Button "Create Draft"
|
||||||
print '<br><div class="center">';
|
print '<br><div class="center">';
|
||||||
print '<input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '">';
|
print '<input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
|
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
@ -3194,7 +3228,10 @@ if ($action == 'create')
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Situations
|
// Situations
|
||||||
if ($object->type == 5 && ($object->situation_counter > 1)) {
|
if (! empty($conf->global->INVOICE_US_SITUATION))
|
||||||
|
{
|
||||||
|
if ($object->type == 5 && ($object->situation_counter > 1))
|
||||||
|
{
|
||||||
$prevsits = $object->get_prev_sits();
|
$prevsits = $object->get_prev_sits();
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $langs->trans('SituationAmount');
|
print $langs->trans('SituationAmount');
|
||||||
@ -3236,6 +3273,7 @@ if ($action == 'create')
|
|||||||
print '<td>' . $langs->trans('Currency' . $conf->currency) . '</td></tr>';
|
print '<td>' . $langs->trans('Currency' . $conf->currency) . '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Amount
|
// Amount
|
||||||
print '<tr><td>' . $langs->trans('AmountHT') . '</td>';
|
print '<tr><td>' . $langs->trans('AmountHT') . '</td>';
|
||||||
@ -3334,6 +3372,13 @@ if ($action == 'create')
|
|||||||
// Lines
|
// Lines
|
||||||
$result = $object->getLinesArray();
|
$result = $object->getLinesArray();
|
||||||
|
|
||||||
|
print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#add' : '#line_' . GETPOST('lineid')) . '" method="POST">
|
||||||
|
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">
|
||||||
|
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateligne') . '">
|
||||||
|
<input type="hidden" name="mode" value="">
|
||||||
|
<input type="hidden" name="id" value="' . $object->id . '">
|
||||||
|
';
|
||||||
|
|
||||||
if (! empty($conf->use_javascript_ajax) && $object->statut == 0) {
|
if (! empty($conf->use_javascript_ajax) && $object->statut == 0) {
|
||||||
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
|
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
|
||||||
}
|
}
|
||||||
@ -3341,6 +3386,8 @@ if ($action == 'create')
|
|||||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||||
|
|
||||||
// Show global modifiers
|
// Show global modifiers
|
||||||
|
if (! empty($conf->global->INVOICE_US_SITUATION))
|
||||||
|
{
|
||||||
if ($object->situation_cycle_ref && $object->statut == 0) {
|
if ($object->situation_cycle_ref && $object->statut == 0) {
|
||||||
print '<tr class="liste_titre nodrag nodrop">';
|
print '<tr class="liste_titre nodrag nodrop">';
|
||||||
print '<form name="updatealllines" id="updatealllines" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '"#updatealllines" method="POST">';
|
print '<form name="updatealllines" id="updatealllines" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '"#updatealllines" method="POST">';
|
||||||
@ -3385,13 +3432,7 @@ if ($action == 'create')
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#add' : '#line_' . GETPOST('lineid')) . '" method="POST">
|
|
||||||
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">
|
|
||||||
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateligne') . '">
|
|
||||||
<input type="hidden" name="mode" value="">
|
|
||||||
<input type="hidden" name="id" value="' . $object->id . '">
|
|
||||||
';
|
|
||||||
|
|
||||||
// Show object lines
|
// Show object lines
|
||||||
if (! empty($object->lines))
|
if (! empty($object->lines))
|
||||||
|
|||||||
@ -202,17 +202,6 @@ class Facture extends CommonInvoice
|
|||||||
if (! $this->cond_reglement_id) $this->cond_reglement_id = 0;
|
if (! $this->cond_reglement_id) $this->cond_reglement_id = 0;
|
||||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||||
$this->brouillon = 1;
|
$this->brouillon = 1;
|
||||||
if (empty($this->situation_cycle_ref)) {
|
|
||||||
$this->situation_cycle_ref = 'null';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($this->situation_counter)) {
|
|
||||||
$this->situation_counter = 'null';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($this->situation_final)) {
|
|
||||||
$this->situation_final = '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::create user=".$user->id);
|
dol_syslog(get_class($this)."::create user=".$user->id);
|
||||||
|
|
||||||
@ -301,12 +290,12 @@ class Facture extends CommonInvoice
|
|||||||
$sql.= ",".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null");
|
$sql.= ",".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null");
|
||||||
$sql.= ",".($user->id > 0 ? "'".$user->id."'":"null");
|
$sql.= ",".($user->id > 0 ? "'".$user->id."'":"null");
|
||||||
$sql.= ",".($this->fk_project?$this->fk_project:"null");
|
$sql.= ",".($this->fk_project?$this->fk_project:"null");
|
||||||
$sql.= ','.$this->cond_reglement_id;
|
$sql.= ", ".$this->cond_reglement_id;
|
||||||
$sql.= ", ".$this->mode_reglement_id;
|
$sql.= ", ".$this->mode_reglement_id;
|
||||||
$sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."'";
|
$sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."'";
|
||||||
$sql.= ", ".$this->situation_cycle_ref;
|
$sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null");
|
||||||
$sql.= ", ".$this->situation_counter;
|
$sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null");
|
||||||
$sql.= ", ".$this->situation_final;
|
$sql.= ", ".($this->situation_final?$this->situation_final:0);
|
||||||
$sql.=")";
|
$sql.=")";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||||
@ -2027,7 +2016,7 @@ class Facture extends CommonInvoice
|
|||||||
* @param int $fk_prev_id Previous situation line id reference
|
* @param int $fk_prev_id Previous situation line id reference
|
||||||
* @return int <0 if KO, Id of line if OK
|
* @return int <0 if KO, Id of line if OK
|
||||||
*/
|
*/
|
||||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=0, $fk_prev_id='')
|
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=100, $fk_prev_id='')
|
||||||
{
|
{
|
||||||
global $mysoc, $conf, $langs;
|
global $mysoc, $conf, $langs;
|
||||||
|
|
||||||
@ -2335,11 +2324,10 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update_percent
|
* Update invoice line with percentage
|
||||||
*
|
*
|
||||||
* @param FactureLigne $line Invoice line
|
* @param FactureLigne $line Invoice line
|
||||||
* @param int $percent percent
|
* @param int $percent Percentage
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function update_percent($line, $percent)
|
function update_percent($line, $percent)
|
||||||
@ -2610,14 +2598,19 @@ class Facture extends CommonInvoice
|
|||||||
else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre';
|
else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre';
|
||||||
else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure';
|
else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure';
|
||||||
|
|
||||||
|
if (! empty($conf->global->FACTURE_ADDON))
|
||||||
|
{
|
||||||
$mybool=false;
|
$mybool=false;
|
||||||
|
|
||||||
$file = $conf->global->FACTURE_ADDON.".php";
|
$file = $conf->global->FACTURE_ADDON.".php";
|
||||||
$classname = $conf->global->FACTURE_ADDON;
|
$classname = $conf->global->FACTURE_ADDON;
|
||||||
// Include file with class
|
// Include file with class
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
{
|
|
||||||
$dir = $dirroot."/core/modules/facture/";
|
foreach ($dirmodels as $reldir) {
|
||||||
|
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/facture/");
|
||||||
|
|
||||||
// Load file with numbering class (if found)
|
// Load file with numbering class (if found)
|
||||||
$mybool|=@include_once $dir.$file;
|
$mybool|=@include_once $dir.$file;
|
||||||
}
|
}
|
||||||
@ -2636,7 +2629,6 @@ class Facture extends CommonInvoice
|
|||||||
$mybool|=@include_once $dir.$file;
|
$mybool|=@include_once $dir.$file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print "xx".$mybool.$dir.$file."-".$classname;
|
|
||||||
|
|
||||||
if (! $mybool)
|
if (! $mybool)
|
||||||
{
|
{
|
||||||
@ -2646,7 +2638,7 @@ class Facture extends CommonInvoice
|
|||||||
|
|
||||||
$obj = new $classname();
|
$obj = new $classname();
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNumRef($soc,$this,$mode);
|
$numref = $obj->getNextValue($soc,$this,$mode);
|
||||||
|
|
||||||
if ($numref != "")
|
if ($numref != "")
|
||||||
{
|
{
|
||||||
@ -2654,8 +2646,15 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
|
dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
|
||||||
return false;
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3455,7 +3454,7 @@ class Facture extends CommonInvoice
|
|||||||
/**
|
/**
|
||||||
* Checks if the invoice is the first of a cycle
|
* Checks if the invoice is the first of a cycle
|
||||||
*
|
*
|
||||||
* @return boolean ($this->situation_counter == 1)
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function is_first()
|
function is_first()
|
||||||
{
|
{
|
||||||
@ -3465,7 +3464,7 @@ class Facture extends CommonInvoice
|
|||||||
/**
|
/**
|
||||||
* Returns an array containing the previous situations as Facture objects
|
* Returns an array containing the previous situations as Facture objects
|
||||||
*
|
*
|
||||||
* @return array array of prev_sits
|
* @return mixed -1 if error, array of previous situations
|
||||||
*/
|
*/
|
||||||
function get_prev_sits()
|
function get_prev_sits()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -553,7 +553,7 @@ if ($resql)
|
|||||||
print_liste_field_titre($langs->trans("Taxes"),$_SERVER["PHP_SELF"],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Taxes"),$_SERVER["PHP_SELF"],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
if (empty($mode))
|
if (empty($mode))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -71,15 +71,17 @@ if ($facid > 0)
|
|||||||
// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
|
||||||
$hookmanager->initHooks(array('paiementcard','globalcard'));
|
$hookmanager->initHooks(array('paiementcard','globalcard'));
|
||||||
|
|
||||||
$parameters=array('socid'=>$socid);
|
|
||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$parameters=array('socid'=>$socid);
|
||||||
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
|
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
|
||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
@ -251,6 +253,7 @@ if ($action == 'confirm_paiement' && $confirm == 'yes')
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -902,7 +902,6 @@ class BonPrelevement extends CommonObject
|
|||||||
$sql.= " ORDER BY ref DESC LIMIT 1";
|
$sql.= " ORDER BY ref DESC LIMIT 1";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG);
|
||||||
dol_syslog(__METHOD__."::Treatments", LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -921,9 +920,7 @@ class BonPrelevement extends CommonObject
|
|||||||
$sql.= ", '".$this->db->idate($now)."'";
|
$sql.= ", '".$this->db->idate($now)."'";
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
|
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
|
||||||
@ -946,8 +943,6 @@ class BonPrelevement extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
dol_syslog(__METHOD__."::Get last withdraw receipt ".$this->db->error(), LOG_ERR);
|
dol_syslog(__METHOD__."::Get last withdraw receipt ".$this->db->error(), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1045,13 +1040,10 @@ class BonPrelevement extends CommonObject
|
|||||||
$sql.= " WHERE rowid = ".$prev_id;
|
$sql.= " WHERE rowid = ".$prev_id;
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
dol_syslog(__METHOD__."::Update total, sql=".$sql, LOG_DEBUG);
|
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog("Erreur mise a jour du total - $sql");
|
|
||||||
dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR);
|
dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -211,23 +211,31 @@ class Contrat extends CommonObject
|
|||||||
global $db, $langs, $conf;
|
global $db, $langs, $conf;
|
||||||
$langs->load("contracts");
|
$langs->load("contracts");
|
||||||
|
|
||||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/contract";
|
if (!empty($conf->global->CONTRACT_ADDON))
|
||||||
|
|
||||||
if (empty($conf->global->CONTRACT_ADDON))
|
|
||||||
{
|
{
|
||||||
$conf->global->CONTRACT_ADDON='mod_contract_serpis';
|
$mybool = false;
|
||||||
}
|
|
||||||
|
|
||||||
$file = $conf->global->CONTRACT_ADDON.".php";
|
$file = $conf->global->CONTRACT_ADDON.".php";
|
||||||
|
|
||||||
// Chargement de la classe de numerotation
|
|
||||||
$classname = $conf->global->CONTRACT_ADDON;
|
$classname = $conf->global->CONTRACT_ADDON;
|
||||||
|
|
||||||
$result=include_once $dir.'/'.$file;
|
// Include file with class
|
||||||
if ($result)
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
{
|
|
||||||
$obj = new $classname();
|
|
||||||
|
|
||||||
|
foreach ($dirmodels as $reldir) {
|
||||||
|
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/contract/");
|
||||||
|
|
||||||
|
// Load file with numbering class (if found)
|
||||||
|
$mybool|=@include_once $dir.$file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $mybool)
|
||||||
|
{
|
||||||
|
dol_print_error('',"Failed to include file ".$file);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj = new $classname();
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNextValue($soc,$this);
|
$numref = $obj->getNextValue($soc,$this);
|
||||||
|
|
||||||
@ -237,13 +245,15 @@ class Contrat extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error = $obj->error;
|
||||||
dol_print_error($db,get_class($this)."::getNextValue ".$obj->error);
|
dol_print_error($db,get_class($this)."::getNextValue ".$obj->error);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_CONTRACT_ADDON_NotDefined");
|
$langs->load("errors");
|
||||||
|
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
64
htdocs/core/actions_printing.inc.php
Normal file
64
htdocs/core/actions_printing.inc.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* 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/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/actions_printing.inc.php
|
||||||
|
* \brief Code for actions print_file to print file with calling trigger
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// $action must be defined
|
||||||
|
// $db, $user, $conf, $langs must be defined
|
||||||
|
// Filename to print must be provided into 'file' parameter
|
||||||
|
|
||||||
|
// Print file
|
||||||
|
if ($action == 'print_file' and $user->rights->printing->read)
|
||||||
|
{
|
||||||
|
$langs->load("printing");
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php';
|
||||||
|
$objectprint = new PrintingDriver($db);
|
||||||
|
$list = $objectprint->listDrivers($db, 10);
|
||||||
|
if (! empty($list)) {
|
||||||
|
$errorprint=0;
|
||||||
|
$printed=0;
|
||||||
|
foreach ($list as $driver) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
||||||
|
$langs->load($driver);
|
||||||
|
$classname = 'printing_'.$driver;
|
||||||
|
$printer = new $classname($db);
|
||||||
|
//print '<pre>'.print_r($printer, true).'</pre>';
|
||||||
|
|
||||||
|
if (! empty($conf->global->{$printer->active})) {
|
||||||
|
$subdir=(GETPOST('printer', 'alpha')=='expedition'?'sending':'');
|
||||||
|
$errorprint = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'), $subdir);
|
||||||
|
//if ($errorprint < 0) {
|
||||||
|
// setEventMessage($interface->errors, 'errors');
|
||||||
|
//}
|
||||||
|
if ($errorprint=='') {
|
||||||
|
setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file'))).' '.$langs->trans("ViaModule").' '.$printer->name);
|
||||||
|
$printed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($printed==0) setEventMessage($langs->trans("NoActivePrintingModuleFound"));
|
||||||
|
} else {
|
||||||
|
setEventMessage($langs->trans("NoModuleFound"), 'warning');
|
||||||
|
}
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* 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/
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/core/actions_printipp.inc.php
|
|
||||||
* \brief Code for actions print_file to print file using ipp
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// $action must be defined
|
|
||||||
// $db, $user, $conf, $langs must be defined
|
|
||||||
// Filename to print must be provided into 'file' parameter
|
|
||||||
|
|
||||||
// Print file
|
|
||||||
if ($action == 'print_file' and $user->rights->printipp->read)
|
|
||||||
{
|
|
||||||
$langs->load("printipp");
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php';
|
|
||||||
$printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD);
|
|
||||||
$result = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'));
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
setEventMessage($result,'warnings');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file'))));
|
|
||||||
}
|
|
||||||
$action = '';
|
|
||||||
}
|
|
||||||
@ -103,7 +103,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
}
|
}
|
||||||
else // Id du contact
|
else // Id du contact
|
||||||
{
|
{
|
||||||
$sendto = $thirdparty->contact_get_property($_POST['receiver'],'email');
|
$sendto = $thirdparty->contact_get_property((int) $_POST['receiver'],'email');
|
||||||
$sendtoid = $_POST['receiver'];
|
$sendtoid = $_POST['receiver'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
}
|
}
|
||||||
else // Id du contact
|
else // Id du contact
|
||||||
{
|
{
|
||||||
$sendtocc = $thirdparty->contact_get_property($_POST['receivercc'],'email');
|
$sendtocc = $thirdparty->contact_get_property((int) $_POST['receivercc'],'email');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -404,7 +404,7 @@ abstract class CommonDocGenerator
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
return array(
|
$resarray= array(
|
||||||
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
|
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
|
||||||
'line_product_ref'=>$line->product_ref,
|
'line_product_ref'=>$line->product_ref,
|
||||||
'line_product_label'=>$line->product_label,
|
'line_product_label'=>$line->product_label,
|
||||||
@ -425,6 +425,18 @@ abstract class CommonDocGenerator
|
|||||||
'line_date_end'=>$line->date_end,
|
'line_date_end'=>$line->date_end,
|
||||||
'line_date_end_rfc'=>dol_print_date($line->date_end,'rfc')
|
'line_date_end_rfc'=>dol_print_date($line->date_end,'rfc')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Retrieve extrafields
|
||||||
|
$extrafieldkey=$line->element;
|
||||||
|
$array_key="line";
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
$extrafields = new ExtraFields($this->db);
|
||||||
|
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
|
||||||
|
$line->fetch_optionals($line->rowid,$extralabels);
|
||||||
|
|
||||||
|
$resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs);
|
||||||
|
|
||||||
|
return $resarray;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2666,7 +2666,7 @@ class Form
|
|||||||
*
|
*
|
||||||
* @return string HTML select
|
* @return string HTML select
|
||||||
*/
|
*/
|
||||||
function load_situation_invoices($selected = '', $socid=null)
|
function load_situation_invoices($selected = '', $socid = '')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
|
|||||||
@ -273,9 +273,9 @@ class FormFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
$printer=0;
|
$printer=0;
|
||||||
if (in_array($modulepart,array('facture','propal','proposal','order','commande'))) // This feature is implemented only for such elements
|
if (in_array($modulepart,array('facture','propal','proposal','order','commande','expedition'))) // This feature is implemented only for such elements
|
||||||
{
|
{
|
||||||
$printer = (!empty($user->rights->printipp->read) && !empty($conf->printipp->enabled))?true:false;
|
$printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$hookmanager->initHooks(array('formfile'));
|
$hookmanager->initHooks(array('formfile'));
|
||||||
@ -604,8 +604,8 @@ class FormFile
|
|||||||
$out.= '<td align="right">';
|
$out.= '<td align="right">';
|
||||||
if ($delallowed)
|
if ($delallowed)
|
||||||
{
|
{
|
||||||
$out.= '<a href="'.$urlsource.(strpos($urlsource,'?')?'&':'?').'action=remove_file&file='.urlencode($relativepath);
|
$out.= '<a href="'.$urlsource.(strpos($urlsource,'?')?'&':'?').'action=remove_file&file='.urlencode($relativepath);
|
||||||
$out.= ($param?'&'.$param:'');
|
$out.= ($param?'&'.$param:'');
|
||||||
//$out.= '&modulepart='.$modulepart; // TODO obsolete ?
|
//$out.= '&modulepart='.$modulepart; // TODO obsolete ?
|
||||||
//$out.= '&urlsource='.urlencode($urlsource); // TODO obsolete ?
|
//$out.= '&urlsource='.urlencode($urlsource); // TODO obsolete ?
|
||||||
$out.= '">'.img_picto($langs->trans("Delete"), 'delete.png').'</a>';
|
$out.= '">'.img_picto($langs->trans("Delete"), 'delete.png').'</a>';
|
||||||
@ -614,9 +614,9 @@ class FormFile
|
|||||||
if ($printer)
|
if ($printer)
|
||||||
{
|
{
|
||||||
//$out.= '<td align="right">';
|
//$out.= '<td align="right">';
|
||||||
$out.= ' <a href="'.$urlsource.(strpos($urlsource,'?')?'&':'?').'action=print_file&printer='.$modulepart.'&file='.urlencode($relativepath);
|
$out.= ' <a href="'.$urlsource.(strpos($urlsource,'?')?'&':'?').'action=print_file&printer='.$modulepart.'&file='.urlencode($relativepath);
|
||||||
$out.= ($param?'&'.$param:'');
|
$out.= ($param?'&'.$param:'');
|
||||||
$out.= '">'.img_picto($langs->trans("Print"),'printer.png').'</a>';
|
$out.= '">'.img_picto($langs->trans("PrintFile", $relativepath),'printer.png').'</a>';
|
||||||
}
|
}
|
||||||
if ($morepicto)
|
if ($morepicto)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -152,7 +152,7 @@ class Menubase
|
|||||||
$sql.= " '".$this->fk_menu."',";
|
$sql.= " '".$this->fk_menu."',";
|
||||||
$sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").",";
|
$sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").",";
|
||||||
$sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").",";
|
$sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").",";
|
||||||
$sql.= " '".$this->position."',";
|
$sql.= " '".(int) $this->position."',";
|
||||||
$sql.= " '".$this->db->escape($this->url)."',";
|
$sql.= " '".$this->db->escape($this->url)."',";
|
||||||
$sql.= " '".$this->db->escape($this->target)."',";
|
$sql.= " '".$this->db->escape($this->target)."',";
|
||||||
$sql.= " '".$this->db->escape($this->titre)."',";
|
$sql.= " '".$this->db->escape($this->titre)."',";
|
||||||
|
|||||||
@ -2456,19 +2456,22 @@ function dol_print_error($db='',$error='')
|
|||||||
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
|
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
|
||||||
{
|
{
|
||||||
$out.=$langs->trans("DolibarrHasDetectedError").".<br>\n";
|
$out.=$langs->trans("DolibarrHasDetectedError").".<br>\n";
|
||||||
if (! empty($conf->global->MAIN_FEATURES_LEVEL))
|
if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $out.="You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.<br>\n";
|
||||||
$out.="You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.<br>\n";
|
|
||||||
$out.=$langs->trans("InformationToHelpDiagnose").":<br>\n";
|
$out.=$langs->trans("InformationToHelpDiagnose").":<br>\n";
|
||||||
|
|
||||||
$out.="<b>".$langs->trans("Date").":</b> ".dol_print_date(time(),'dayhourlog')."<br>\n";;
|
$out.="<b>".$langs->trans("Date").":</b> ".dol_print_date(time(),'dayhourlog')."<br>\n";
|
||||||
$out.="<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";;
|
$out.="<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";
|
||||||
if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="<b>".$langs->trans("LevelOfFeature").":</b> ".$conf->global->MAIN_FEATURES_LEVEL."<br>\n";;
|
if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="<b>".$langs->trans("LevelOfFeature").":</b> ".$conf->global->MAIN_FEATURES_LEVEL."<br>\n";
|
||||||
if (function_exists("phpversion"))
|
if (function_exists("phpversion"))
|
||||||
{
|
{
|
||||||
$out.="<b>".$langs->trans("PHP").":</b> ".phpversion()."<br>\n";
|
$out.="<b>".$langs->trans("PHP").":</b> ".phpversion()."<br>\n";
|
||||||
//phpinfo(); // This is to show location of php.ini file
|
|
||||||
}
|
}
|
||||||
$out.="<b>".$langs->trans("Server").":</b> ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
|
$out.="<b>".$langs->trans("Server").":</b> ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
|
||||||
|
if (function_exists("php_uname"))
|
||||||
|
{
|
||||||
|
$out.="<b>".$langs->trans("OS").":</b> ".php_uname()."<br>\n";
|
||||||
|
}
|
||||||
|
$out.="<b>".$langs->trans("UserAgent").":</b> ".$_SERVER["HTTP_USER_AGENT"]."<br>\n";
|
||||||
$out.="<br>\n";
|
$out.="<br>\n";
|
||||||
$out.="<b>".$langs->trans("RequestedUrl").":</b> ".dol_htmlentities($_SERVER["REQUEST_URI"],ENT_COMPAT,'UTF-8')."<br>\n";
|
$out.="<b>".$langs->trans("RequestedUrl").":</b> ".dol_htmlentities($_SERVER["REQUEST_URI"],ENT_COMPAT,'UTF-8')."<br>\n";
|
||||||
$out.="<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."<br>\n";
|
$out.="<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."<br>\n";
|
||||||
|
|||||||
@ -49,7 +49,7 @@
|
|||||||
* @param int $type 0/1=Product/service
|
* @param int $type 0/1=Product/service
|
||||||
* @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc.
|
* @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc.
|
||||||
* @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate function).
|
* @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate function).
|
||||||
* @param float $progress Situation invoices progress
|
* @param float $progress Situation invoices progress (value from 0 to 100, 100 by default)
|
||||||
* @return result[ 0=total_ht,
|
* @return result[ 0=total_ht,
|
||||||
* 1=total_vat,
|
* 1=total_vat,
|
||||||
* 2=total_ttc,
|
* 2=total_ttc,
|
||||||
@ -97,6 +97,8 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
|||||||
if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj;
|
if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj;
|
||||||
if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj;
|
if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj;
|
||||||
|
|
||||||
|
dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress);
|
||||||
|
|
||||||
// Now we search localtaxes information ourself (rates and types).
|
// Now we search localtaxes information ourself (rates and types).
|
||||||
$localtax1_type=0;
|
$localtax1_type=0;
|
||||||
$localtax2_type=0;
|
$localtax2_type=0;
|
||||||
|
|||||||
@ -344,7 +344,8 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the translated module name if translation exists in admin.lang or the default module name.
|
* Gives the translated module name if translation exists in admin.lang or into language files of module.
|
||||||
|
* Otherwise return the module key name.
|
||||||
*
|
*
|
||||||
* @return string Translated module name
|
* @return string Translated module name
|
||||||
*/
|
*/
|
||||||
@ -360,8 +361,15 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If module name translation using it's unique id does not exists, we take its name
|
// If module name translation using it's unique id does not exists, we take use its name to find translation
|
||||||
return $this->name;
|
if (is_array($this->langfiles))
|
||||||
|
{
|
||||||
|
foreach($this->langfiles as $val)
|
||||||
|
{
|
||||||
|
if ($val) $langs->load($val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $langs->trans($this->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,8 +391,15 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If module description translation using it's unique id does not exists, we take its description
|
// If module description translation using it's unique id does not exists, we take use its name to find translation
|
||||||
return $this->description;
|
if (is_array($this->langfiles))
|
||||||
|
{
|
||||||
|
foreach($this->langfiles as $val)
|
||||||
|
{
|
||||||
|
if ($val) $langs->load($val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $langs->trans($this->description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,6 +883,8 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
|
if (empty($this->const)) return 0;
|
||||||
|
|
||||||
foreach ($this->const as $key => $value)
|
foreach ($this->const as $key => $value)
|
||||||
{
|
{
|
||||||
$name = $this->const[$key][0];
|
$name = $this->const[$key][0];
|
||||||
@ -935,6 +952,8 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
|
if (empty($this->const)) return 0;
|
||||||
|
|
||||||
foreach ($this->const as $key => $value)
|
foreach ($this->const as $key => $value)
|
||||||
{
|
{
|
||||||
$name = $this->const[$key][0];
|
$name = $this->const[$key][0];
|
||||||
|
|||||||
@ -95,17 +95,17 @@ class modDeplacement extends DolibarrModules
|
|||||||
$this->rights[3][3] = 0;
|
$this->rights[3][3] = 0;
|
||||||
$this->rights[3][4] = 'supprimer';
|
$this->rights[3][4] = 'supprimer';
|
||||||
|
|
||||||
$this->rights[3][0] = 174;
|
$this->rights[4][0] = 174;
|
||||||
$this->rights[3][1] = 'Lire toutes les notes de frais';
|
$this->rights[4][1] = 'Lire toutes les notes de frais';
|
||||||
$this->rights[3][2] = 'd';
|
$this->rights[4][2] = 'd';
|
||||||
$this->rights[3][3] = 0;
|
$this->rights[4][3] = 0;
|
||||||
$this->rights[3][4] = 'readall';
|
$this->rights[4][4] = 'readall';
|
||||||
|
|
||||||
$this->rights[6][0] = 178;
|
$this->rights[5][0] = 178;
|
||||||
$this->rights[6][1] = 'Exporter les notes de frais et deplacements';
|
$this->rights[5][1] = 'Exporter les notes de frais et deplacements';
|
||||||
$this->rights[6][2] = 'd';
|
$this->rights[5][2] = 'd';
|
||||||
$this->rights[6][3] = 0;
|
$this->rights[5][3] = 0;
|
||||||
$this->rights[6][4] = 'export';
|
$this->rights[5][4] = 'export';
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
$r=0;
|
$r=0;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -15,27 +16,26 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \defgroup printipp Module printipp
|
/** \defgroup printing Module printing
|
||||||
* \brief Module pour imprimer via CUPS
|
* \brief Module for activation of printing icon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/core/modules/modPrintIPP.class.php
|
* \file htdocs/core/modules/modPrinting.class.php
|
||||||
* \ingroup printipp
|
* \ingroup printing
|
||||||
* \brief Fichier de description et activation du module OSCommerce2
|
* \brief Fichier de description et activation du module Printing
|
||||||
*/
|
*/
|
||||||
include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
|
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class modPrintIPP
|
* \class modPrinting
|
||||||
* \brief Classe de description et activation du module PrintIPP
|
* \brief Classe de description et activation du module Printing
|
||||||
*/
|
*/
|
||||||
class modPrintIPP extends DolibarrModules
|
class modPrinting extends DolibarrModules
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -44,13 +44,13 @@ class modPrintIPP extends DolibarrModules
|
|||||||
function __construct($db)
|
function __construct($db)
|
||||||
{
|
{
|
||||||
$this->db = $db ;
|
$this->db = $db ;
|
||||||
$this->numero = 54000;
|
$this->numero = 112000;
|
||||||
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
|
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
|
||||||
// It is used to group modules in module setup page
|
// It is used to group modules in module setup page
|
||||||
$this->family = "other";
|
$this->family = "other";
|
||||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||||
$this->description = "Print via Cups IPP Printer.";
|
$this->description = "Enable Printing System.";
|
||||||
$this->version = 'dolibarr'; // '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);
|
$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)
|
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||||
@ -64,16 +64,15 @@ class modPrintIPP extends DolibarrModules
|
|||||||
$this->dirs = array();
|
$this->dirs = array();
|
||||||
|
|
||||||
// Config pages
|
// Config pages
|
||||||
$this->config_page_url = array("printipp.php@printipp");
|
$this->config_page_url = array("printing.php@printing");
|
||||||
|
|
||||||
// Dependances
|
// Dependances
|
||||||
$this->hidden = (! empty($_SERVER["WINDIR"]));
|
|
||||||
$this->depends = array();
|
$this->depends = array();
|
||||||
$this->requiredby = array();
|
$this->requiredby = array();
|
||||||
$this->phpmin = array(5,1); // Minimum version of PHP required by module
|
$this->phpmin = array(5,1); // Minimum version of PHP required by module
|
||||||
$this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module
|
$this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module
|
||||||
$this->conflictwith = array();
|
$this->conflictwith = array();
|
||||||
$this->langfiles = array("printipp");
|
$this->langfiles = array("printing");
|
||||||
|
|
||||||
// Constantes
|
// Constantes
|
||||||
$this->const = array();
|
$this->const = array();
|
||||||
@ -83,7 +82,7 @@ class modPrintIPP extends DolibarrModules
|
|||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
$this->rights = array();
|
$this->rights = array();
|
||||||
$this->rights_class = 'printipp';
|
$this->rights_class = 'printing';
|
||||||
|
|
||||||
$r=0;
|
$r=0;
|
||||||
// $this->rights[$r][0] Id permission (unique tous modules confondus)
|
// $this->rights[$r][0] Id permission (unique tous modules confondus)
|
||||||
@ -94,8 +93,8 @@ class modPrintIPP extends DolibarrModules
|
|||||||
// $this->rights[$r][5] Niveau 2 pour nommer permission dans code
|
// $this->rights[$r][5] Niveau 2 pour nommer permission dans code
|
||||||
|
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = 54001;
|
$this->rights[$r][0] = 112001;
|
||||||
$this->rights[$r][1] = 'Printer';
|
$this->rights[$r][1] = 'Printing';
|
||||||
$this->rights[$r][2] = 'r';
|
$this->rights[$r][2] = 'r';
|
||||||
$this->rights[$r][3] = 1;
|
$this->rights[$r][3] = 1;
|
||||||
$this->rights[$r][4] = 'read';
|
$this->rights[$r][4] = 'read';
|
||||||
@ -107,13 +106,13 @@ class modPrintIPP extends DolibarrModules
|
|||||||
// This is to declare the Top Menu entry:
|
// This is to declare the Top Menu entry:
|
||||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Put 0 if this is a top menu
|
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Put 0 if this is a top menu
|
||||||
'type'=>'left', // This is a Top menu entry
|
'type'=>'left', // This is a Top menu entry
|
||||||
'titre'=>'Printer',
|
'titre'=>'Printing',
|
||||||
'mainmenu'=>'printer',
|
'mainmenu'=>'printing',
|
||||||
'url'=>'/printipp/index.php',
|
'url'=>'/printing/index.php',
|
||||||
'langs'=>'printipp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
'position'=>300,
|
'position'=>300,
|
||||||
'enabled'=>'$conf->printipp->enabled && $leftmenu==\'modulesadmintools\'',
|
'enabled'=>'$conf->printing->enabled && $leftmenu==\'modulesadmintools\'',
|
||||||
'perms'=>'$user->rights->printipp->read', // Use 'perms'=>'1' if you want your menu with no permission rules
|
'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules
|
||||||
'target'=>'',
|
'target'=>'',
|
||||||
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
|
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
|
|
||||||
86
htdocs/core/modules/printing/modules_printing.php
Normal file
86
htdocs/core/modules/printing/modules_printing.php
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* 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/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/modules/mailings/modules_printing.php
|
||||||
|
* \ingroup printing
|
||||||
|
* \brief File with parent class of printing modules
|
||||||
|
*/
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parent class of emailing target selectors modules
|
||||||
|
*/
|
||||||
|
class PrintingDriver
|
||||||
|
{
|
||||||
|
var $db;
|
||||||
|
var $error;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
function __construct($db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of printing driver
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
* @param string $maxfilenamelength Max length of value to show
|
||||||
|
* @return array List of drivers
|
||||||
|
*/
|
||||||
|
static function listDrivers($db,$maxfilenamelength=0)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$type='printing';
|
||||||
|
$liste=array();
|
||||||
|
|
||||||
|
$moduledir=DOL_DOCUMENT_ROOT."/core/modules/printing/";
|
||||||
|
$tmpfiles=dol_dir_list($moduledir,'all',0,'\modules.php','','name',SORT_ASC,0);
|
||||||
|
foreach($tmpfiles as $record) {
|
||||||
|
$list[$record['fullname']]=str_replace('.modules.php', '',$record['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return description of Printing Module
|
||||||
|
*
|
||||||
|
* @return string Return translation of key PrintingModuleDescXXX where XXX is module name, or $this->desc if not exists
|
||||||
|
*/
|
||||||
|
function getDesc()
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
$langs->load("printing");
|
||||||
|
$transstring="PrintingModuleDesc".$this->name;
|
||||||
|
if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring);
|
||||||
|
else return $this->desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
355
htdocs/core/modules/printing/printgcp.modules.php
Normal file
355
htdocs/core/modules/printing/printgcp.modules.php
Normal file
@ -0,0 +1,355 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* 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/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/modules/printing/printgcp.modules.php
|
||||||
|
* \ingroup printing
|
||||||
|
* \brief File to provide printing with Google Cloud Print
|
||||||
|
*/
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class mailing_example
|
||||||
|
* \brief Class to provide printing with Google Cloud Print
|
||||||
|
*/
|
||||||
|
class printing_printgcp extends PrintingDriver
|
||||||
|
{
|
||||||
|
var $name = 'printgcp';
|
||||||
|
var $desc = 'PrintGCPDesc';
|
||||||
|
var $picto = 'printer';
|
||||||
|
var $active = 'PRINTING_PRINTGCP';
|
||||||
|
var $conf = array();
|
||||||
|
var $login = '';
|
||||||
|
var $password = '';
|
||||||
|
var $authtoken = '';
|
||||||
|
var $db;
|
||||||
|
|
||||||
|
const LOGIN_URL = 'https://www.google.com/accounts/ClientLogin';
|
||||||
|
const PRINTERS_SEARCH_URL = 'https://www.google.com/cloudprint/interface/search';
|
||||||
|
const PRINT_URL = 'https://www.google.com/cloudprint/interface/submit';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
function __construct($db)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$this->db = $db;
|
||||||
|
$this->login = $conf->global->PRINTGCP_LOGIN;
|
||||||
|
$this->password = $conf->global->PRINTGCP_PASSWORD;
|
||||||
|
$this->authtoken = $conf->global->PRINTGCP_AUTHTOKEN;
|
||||||
|
$this->conf[] = array('varname'=>'PRINTGCP_LOGIN', 'required'=>1, 'example'=>'user@gmail.com', 'type'=>'text');
|
||||||
|
$this->conf[] = array('varname'=>'PRINTGCP_PASSWORD', 'required'=>1, 'example'=>'', 'type'=>'password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of available printers
|
||||||
|
*
|
||||||
|
* @return string html list of printers
|
||||||
|
*/
|
||||||
|
function listAvailablePrinters()
|
||||||
|
{
|
||||||
|
global $bc, $conf, $langs;
|
||||||
|
$langs->load('printgcp');
|
||||||
|
$var=true;
|
||||||
|
|
||||||
|
$html = '<tr class="liste_titre">';
|
||||||
|
$html.= '<td>'.$langs->trans('GCP_Name').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('GCP_displayName').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('GCP_Id').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('GCP_OwnerName').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('GCP_State').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('GCP_connectionStatus').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('GCP_Type').'</td>';
|
||||||
|
$html.= '<td align="center">'.$langs->trans("Select").'</td>';
|
||||||
|
$html.= '</tr>'."\n";
|
||||||
|
$list = $this->getlist_available_printers();
|
||||||
|
//$html.= '<td><pre>'.print_r($list,true).'</pre></td>';
|
||||||
|
$var = true;
|
||||||
|
foreach ($list['available'] as $printer_det)
|
||||||
|
{
|
||||||
|
$var=!$var;
|
||||||
|
$html.= "<tr ".$bc[$var].">";
|
||||||
|
$html.= '<td>'.$printer_det['name'].'</td>';
|
||||||
|
$html.= '<td>'.$printer_det['displayName'].'</td>';
|
||||||
|
$html.= '<td>'.$printer_det['id'].'</td>'; // id to identify printer to use
|
||||||
|
$html.= '<td>'.$printer_det['ownerName'].'</td>';
|
||||||
|
$html.= '<td>'.$printer_det['status'].'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('STATE_'.$printer_det['connectionStatus']).'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('TYPE_'.$printer_det['type']).'</td>';
|
||||||
|
// Defaut
|
||||||
|
$html.= '<td align="center">';
|
||||||
|
if ($conf->global->PRINTING_GCP_DEFAULT == $printer_det['id'])
|
||||||
|
{
|
||||||
|
$html.= img_picto($langs->trans("Default"),'on');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTING_GCP_DEFAULT&driver=printgcp&value='.urlencode($printer_det['id']).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||||
|
$html.= '</td>';
|
||||||
|
$html.= '</tr>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of available printers
|
||||||
|
*
|
||||||
|
* @return array list of printers
|
||||||
|
*/
|
||||||
|
function getlist_available_printers()
|
||||||
|
{
|
||||||
|
global $conf,$db;
|
||||||
|
if ($this->authtoken=='') {
|
||||||
|
$this->GoogleLogin();
|
||||||
|
}
|
||||||
|
$ret['available'] = $this->get_printer_detail();
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of printers
|
||||||
|
*
|
||||||
|
* @return array list of printers
|
||||||
|
*/
|
||||||
|
function get_printer_detail()
|
||||||
|
{
|
||||||
|
// Check if we have auth token
|
||||||
|
if(empty($this->authtoken)) {
|
||||||
|
// We don't have auth token so throw exception
|
||||||
|
throw new Exception("Please first login to Google by calling loginToGoogle function");
|
||||||
|
}
|
||||||
|
// Prepare auth headers with auth token
|
||||||
|
$authheaders = array("Authorization: GoogleLogin auth=".$this->authtoken,
|
||||||
|
"GData-Version: 3.0",
|
||||||
|
);
|
||||||
|
// Make Http call to get printers added by user to Google Cloud Print
|
||||||
|
$responsedata = $this->makeCurl(self::PRINTERS_SEARCH_URL,array(),$authheaders);
|
||||||
|
$printers = json_decode($responsedata);
|
||||||
|
// Check if we have printers?
|
||||||
|
if(is_null($printers)) {
|
||||||
|
// We dont have printers so return blank array
|
||||||
|
return array();
|
||||||
|
} else {
|
||||||
|
// We have printers so returns printers as array
|
||||||
|
return $this->parsePrinters($printers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print selected file
|
||||||
|
*
|
||||||
|
* @param string $file file
|
||||||
|
* @param string $module module
|
||||||
|
* @param string $subdir subdir for file
|
||||||
|
* @return string '' if OK, Error message if KO
|
||||||
|
*/
|
||||||
|
function print_file($file, $module, $subdir='')
|
||||||
|
{
|
||||||
|
global $conf, $user, $db;
|
||||||
|
if ($this->authtoken=='') {
|
||||||
|
$this->GoogleLogin();
|
||||||
|
}
|
||||||
|
// si $module=commande_fournisseur alors $conf->fournisseur->commande->dir_output
|
||||||
|
$fileprint=$conf->{$module}->dir_output;
|
||||||
|
if ($subdir!='') $fileprint.='/'.$subdir;
|
||||||
|
$fileprint.='/'.$file;
|
||||||
|
// select printer uri for module order, propal,...
|
||||||
|
$sql = 'SELECT rowid, printer_id, copy FROM '.MAIN_DB_PREFIX.'printing WHERE module="'.$module.'" AND driver="printgcp" AND userid='.$user->id;
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
if ($obj)
|
||||||
|
{
|
||||||
|
$printer_id=$obj->printer_id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->PRINTING_GCP_DEFAULT))
|
||||||
|
{
|
||||||
|
$printer_id=$conf->global->PRINTING_GCP_DEFAULT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 'NoDefaultPrinterDefined';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->sendPrintToPrinter($printer_id, $file, $fileprint, 'application/pdf');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends document to the printer
|
||||||
|
*
|
||||||
|
* @param string $printerid Printer id returned by Google Cloud Print
|
||||||
|
* @param string $printjobtitle Job Title
|
||||||
|
* @param string $filepath File Path to be send to Google Cloud Print
|
||||||
|
* @param string $contenttype File content type by example application/pdf, image/png
|
||||||
|
* @return array status array
|
||||||
|
*/
|
||||||
|
public function sendPrintToPrinter($printerid,$printjobtitle,$filepath,$contenttype)
|
||||||
|
{
|
||||||
|
$errors=0;
|
||||||
|
// Check auth token
|
||||||
|
if(empty($this->authtoken)) {
|
||||||
|
$errors++;
|
||||||
|
setEventMessage('Please first login to Google', 'warning');
|
||||||
|
}
|
||||||
|
// Check if printer id
|
||||||
|
if(empty($printerid)) {
|
||||||
|
$errors++;
|
||||||
|
setEventMessage('No provided printer ID', 'warning');
|
||||||
|
}
|
||||||
|
// Open the file which needs to be print
|
||||||
|
$handle = fopen($filepath, "rb");
|
||||||
|
if(!$handle) {
|
||||||
|
$errors++;
|
||||||
|
setEventMessage('Could not read the file.');
|
||||||
|
}
|
||||||
|
// Read file content
|
||||||
|
$contents = fread($handle, filesize($filepath));
|
||||||
|
fclose($handle);
|
||||||
|
// Prepare post fields for sending print
|
||||||
|
$post_fields = array('printerid' => $printerid,
|
||||||
|
'title' => $printjobtitle,
|
||||||
|
'contentTransferEncoding' => 'base64',
|
||||||
|
'content' => base64_encode($contents), // encode file content as base64
|
||||||
|
'contentType' => $contenttype
|
||||||
|
);
|
||||||
|
// Prepare authorization headers
|
||||||
|
$authheaders = array("Authorization: GoogleLogin auth=" . $this->authtoken);
|
||||||
|
// Make http call for sending print Job
|
||||||
|
$response = json_decode($this->makeCurl(self::PRINT_URL,$post_fields,$authheaders));
|
||||||
|
// Has document been successfully sent?
|
||||||
|
if($response->success=="1") {
|
||||||
|
return array('status' =>true,'errorcode' =>'','errormessage'=>"");
|
||||||
|
} else {
|
||||||
|
return array('status' =>false,'errorcode' =>$response->errorCode,'errormessage'=>$response->message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login into Google Account
|
||||||
|
*
|
||||||
|
* @return string true or false
|
||||||
|
*/
|
||||||
|
function GoogleLogin()
|
||||||
|
{
|
||||||
|
global $db, $conf;
|
||||||
|
// Prepare post fields required for the login
|
||||||
|
$loginpostfields = array("accountType" => "HOSTED_OR_GOOGLE",
|
||||||
|
"Email" => $this->login,
|
||||||
|
"Passwd" => $this->password,
|
||||||
|
"service" => "cloudprint",
|
||||||
|
"source" => "GCP"
|
||||||
|
);
|
||||||
|
// Get the Auth token
|
||||||
|
$loginresponse = $this->makeCurl(self::LOGIN_URL,$loginpostfields);
|
||||||
|
$token = $this->getAuthToken($loginresponse);
|
||||||
|
if(! empty($token)&&!is_null($token)) {
|
||||||
|
$this->authtoken = $token;
|
||||||
|
$result=dolibarr_set_const($db, 'PRINTGCP_AUTHTOKEN', $token, 'chaine', 0, '', $conf->entity);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse json response and return printers array
|
||||||
|
*
|
||||||
|
* @param string $jsonobj Json response object
|
||||||
|
* @return array return array of printers
|
||||||
|
*/
|
||||||
|
private function parsePrinters($jsonobj)
|
||||||
|
{
|
||||||
|
$printers = array();
|
||||||
|
if (isset($jsonobj->printers)) {
|
||||||
|
foreach ($jsonobj->printers as $gcpprinter) {
|
||||||
|
$printers[] = array('id' =>$gcpprinter->id,
|
||||||
|
'name' =>$gcpprinter->name,
|
||||||
|
'defaultDisplayName' =>$gcpprinter->defaultDisplayName,
|
||||||
|
'displayName' =>$gcpprinter->displayName,
|
||||||
|
'ownerId' =>$gcpprinter->ownerId,
|
||||||
|
'ownerName' =>$gcpprinter->ownerName,
|
||||||
|
'connectionStatus' =>$gcpprinter->connectionStatus,
|
||||||
|
'status' =>$gcpprinter->status,
|
||||||
|
'type' =>$gcpprinter->type
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $printers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse data to get auth token
|
||||||
|
*
|
||||||
|
* @param string $response response from curl
|
||||||
|
* @return string token
|
||||||
|
*/
|
||||||
|
private function getAuthToken($response)
|
||||||
|
{
|
||||||
|
// Search Auth tag
|
||||||
|
preg_match("/Auth=([a-z0-9_-]+)/i", $response, $matches);
|
||||||
|
$authtoken = @$matches[1];
|
||||||
|
return $authtoken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Curl request
|
||||||
|
*
|
||||||
|
* @param string $url url to hit
|
||||||
|
* @param array $postfields array of post fields
|
||||||
|
* @param array $headers array of http headers
|
||||||
|
* @return array response from curl
|
||||||
|
*/
|
||||||
|
private function makeCurl($url,$postfields=array(),$headers=array())
|
||||||
|
{
|
||||||
|
// Curl Init
|
||||||
|
$curl = curl_init($url);
|
||||||
|
// Curl post request
|
||||||
|
if(! empty($postfields)) {
|
||||||
|
// As is HTTP post curl request so set post fields
|
||||||
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
|
||||||
|
}
|
||||||
|
// Curl request headers
|
||||||
|
if(! empty($headers)) {
|
||||||
|
// As curl requires header so set headers here
|
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
}
|
||||||
|
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
// Execute the curl and return response
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
curl_close($curl);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
284
htdocs/core/modules/printing/printipp.modules.php
Normal file
284
htdocs/core/modules/printing/printipp.modules.php
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* 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/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/modules/printing/printipp.modules.php
|
||||||
|
* \ingroup mailing
|
||||||
|
* \brief File to provide printing with PrintIPP
|
||||||
|
*/
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class mailing_example
|
||||||
|
* \brief Class to provide printing with PrintIPP
|
||||||
|
*/
|
||||||
|
class printing_printipp extends PrintingDriver
|
||||||
|
{
|
||||||
|
var $name='printipp';
|
||||||
|
var $desc='PrintIPPDesc';
|
||||||
|
var $picto='printer';
|
||||||
|
var $active='PRINTING_PRINTIPP';
|
||||||
|
var $conf=array();
|
||||||
|
var $host;
|
||||||
|
var $port;
|
||||||
|
var $userid; /* user login */
|
||||||
|
var $user;
|
||||||
|
var $password;
|
||||||
|
var $error;
|
||||||
|
var $db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
function __construct($db)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$this->db=$db;
|
||||||
|
$this->host=$conf->global->PRINTIPP_HOST;
|
||||||
|
$this->port=$conf->global->PRINTIPP_PORT;
|
||||||
|
$this->user=$conf->global->PRINTIPP_USER;
|
||||||
|
$this->password=$conf->global->PRINTIPP_PASSWORD;
|
||||||
|
$this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text');
|
||||||
|
$this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text');
|
||||||
|
$this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text');
|
||||||
|
$this->conf[] = array('varname'=>'PRINTIPP_PASSWORD', 'required'=>0, 'example'=>'', 'type'=>'password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print selected file
|
||||||
|
*
|
||||||
|
* @param string $file file
|
||||||
|
* @param string $module module
|
||||||
|
* @param string $subdir subdirectory of document like for expedition subdir is sendings
|
||||||
|
*
|
||||||
|
* @return string '' if OK, Error message if KO
|
||||||
|
*/
|
||||||
|
function print_file($file, $module, $subdir='')
|
||||||
|
{
|
||||||
|
global $conf, $user, $db;
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||||
|
|
||||||
|
$ipp = new CupsPrintIPP();
|
||||||
|
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
|
||||||
|
$ipp->setHost($this->host);
|
||||||
|
$ipp->setPort($this->port);
|
||||||
|
$ipp->setJobName($file,true);
|
||||||
|
$ipp->setUserName($this->userid);
|
||||||
|
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
|
||||||
|
|
||||||
|
// select printer uri for module order, propal,...
|
||||||
|
$sql = 'SELECT rowid,printer_id,copy FROM '.MAIN_DB_PREFIX.'printing WHERE module="'.$module.'" AND driver="printipp" AND userid='.$user->id;
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
if ($obj)
|
||||||
|
{
|
||||||
|
$ipp->setPrinterURI($obj->printer_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->PRINTIPP_URI_DEFAULT))
|
||||||
|
{
|
||||||
|
$ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 'NoDefaultPrinterDefined';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set number of copy
|
||||||
|
$ipp->setCopies($obj->copy);
|
||||||
|
$fileprint=$conf->{$module}->dir_output;
|
||||||
|
if ($subdir!='') $fileprint.='/'.$subdir;
|
||||||
|
$fileprint.='/'.$file;
|
||||||
|
$ipp->setData($fileprint);
|
||||||
|
$ipp->printJob();
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of available printers
|
||||||
|
*
|
||||||
|
* @return string html list of printers
|
||||||
|
*/
|
||||||
|
function listAvailablePrinters()
|
||||||
|
{
|
||||||
|
global $bc, $conf, $langs;
|
||||||
|
$var=true;
|
||||||
|
|
||||||
|
$html = '<tr class="liste_titre">';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_Uri').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_Name').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_State').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_State_reason').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_State_reason1').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_BW').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_Color').'</td>';
|
||||||
|
//$html.= '<td>'.$langs->trans('IPP_Device').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_Media').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_Supported').'</td>';
|
||||||
|
$html.= '<td align="center">'.$langs->trans("Select").'</td>';
|
||||||
|
$html.= "</tr>\n";
|
||||||
|
$list = $this->getlist_available_printers();
|
||||||
|
$var = true;
|
||||||
|
foreach ($list as $value)
|
||||||
|
{
|
||||||
|
$var=!$var;
|
||||||
|
$printer_det = $this->get_printer_detail($value);
|
||||||
|
$html.= "<tr ".$bc[$var].">";
|
||||||
|
$html.= '<td>'.$value.'</td>';
|
||||||
|
//$html.= '<td><pre>'.print_r($printer_det,true).'</pre></td>';
|
||||||
|
$html.= '<td>'.$printer_det->printer_name->_value0.'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).'</td>';
|
||||||
|
$html.= '<td>'.(! empty($printer_det->printer_state_reasons->_value1)?$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1):'').'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).'</td>';
|
||||||
|
//$html.= '<td>'.$printer_det->device_uri->_value0.'</td>';
|
||||||
|
$html.= '<td>'.$printer_det->media_default->_value0.'</td>';
|
||||||
|
$html.= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>';
|
||||||
|
// Defaut
|
||||||
|
$html.= '<td align="center">';
|
||||||
|
if ($conf->global->PRINTIPP_URI_DEFAULT == $value)
|
||||||
|
{
|
||||||
|
$html.= img_picto($langs->trans("Default"),'on');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||||
|
$html.= '</td>';
|
||||||
|
$html.= '</tr>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of available printers
|
||||||
|
*
|
||||||
|
* @return array list of printers
|
||||||
|
*/
|
||||||
|
function getlist_available_printers()
|
||||||
|
{
|
||||||
|
global $conf,$db;
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||||
|
$ipp = new CupsPrintIPP();
|
||||||
|
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
|
||||||
|
$ipp->setHost($this->host);
|
||||||
|
$ipp->setPort($this->port);
|
||||||
|
$ipp->setUserName($this->userid);
|
||||||
|
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
|
||||||
|
$ipp->getPrinters();
|
||||||
|
return $ipp->available_printers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get printer detail
|
||||||
|
*
|
||||||
|
* @param string $uri URI
|
||||||
|
* @return array List of attributes
|
||||||
|
*/
|
||||||
|
function get_printer_detail($uri)
|
||||||
|
{
|
||||||
|
global $conf,$db;
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||||
|
$ipp = new CupsPrintIPP();
|
||||||
|
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
|
||||||
|
$ipp->setHost($this->host);
|
||||||
|
$ipp->setPort($this->port);
|
||||||
|
$ipp->setUserName($this->userid);
|
||||||
|
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
|
||||||
|
$ipp->setPrinterURI($uri);
|
||||||
|
$ipp->getPrinterAttributes();
|
||||||
|
return $ipp->printer_attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List jobs print
|
||||||
|
*
|
||||||
|
* @param string $module module
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function list_jobs($module)
|
||||||
|
{
|
||||||
|
global $conf, $db, $bc;
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
|
||||||
|
$ipp = new CupsPrintIPP();
|
||||||
|
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
|
||||||
|
$ipp->setHost($this->host);
|
||||||
|
$ipp->setPort($this->port);
|
||||||
|
$ipp->setUserName($this->userid);
|
||||||
|
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password);
|
||||||
|
// select printer uri for module order, propal,...
|
||||||
|
$sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"';
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
if ($obj)
|
||||||
|
{
|
||||||
|
$ipp->setPrinterURI($obj->printer_uri);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// All printers
|
||||||
|
$ipp->setPrinterURI("ipp://localhost:631/printers/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Getting Jobs
|
||||||
|
$ipp->getJobs(false,0,'completed',false);
|
||||||
|
print '<table width="100%" class="noborder">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print "<td>Id</td>";
|
||||||
|
print "<td>Owner</td>";
|
||||||
|
print "<td>Printer</td>";
|
||||||
|
print "<td>File</td>";
|
||||||
|
print "<td>Status</td>";
|
||||||
|
print "<td>Cancel</td>";
|
||||||
|
print "</tr>\n";
|
||||||
|
$jobs = $ipp->jobs_attributes;
|
||||||
|
$var = True;
|
||||||
|
//print '<pre>'.print_r($jobs,true).'</pre>';
|
||||||
|
foreach ($jobs as $value )
|
||||||
|
{
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr ".$bc[$var].">";
|
||||||
|
print '<td>'.$value->job_id->_value0.'</td>';
|
||||||
|
print '<td>'.$value->job_originating_user_name->_value0.'</td>';
|
||||||
|
print '<td>'.$value->printer_uri->_value0.'</td>';
|
||||||
|
print '<td>'.$value->job_name->_value0.'</td>';
|
||||||
|
print '<td>'.$value->job_state->_value0.'</td>';
|
||||||
|
print '<td>'.$value->job_uri->_value0.'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
print "</table>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -125,7 +125,8 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->datef);
|
//Supplier invoices take invoice date instead of creation date for the mask
|
||||||
|
$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->date);
|
||||||
|
|
||||||
return $numFinal;
|
return $numFinal;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -353,16 +353,20 @@ if (($action=="create") || ($action=="edit"))
|
|||||||
print "<tr><td>";
|
print "<tr><td>";
|
||||||
print $langs->trans('CronEvery')."</td>";
|
print $langs->trans('CronEvery')."</td>";
|
||||||
print "<td><select name=\"nbfrequency\">";
|
print "<td><select name=\"nbfrequency\">";
|
||||||
for($i=1; $i<=60; $i++){
|
for($i=1; $i<=60; $i++)
|
||||||
if(($object->frequency/$object->unitfrequency) == $i){
|
{
|
||||||
|
if (! empty($object->unitfrequency) && ($object->frequency/$object->unitfrequency) == $i)
|
||||||
|
{
|
||||||
print "<option value='".$i."' selected='selected'>".$i."</option>";
|
print "<option value='".$i."' selected='selected'>".$i."</option>";
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
print "<option value='".$i."'>".$i."</option>";
|
print "<option value='".$i."'>".$i."</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$input = "<input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
|
$input = "<input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
|
||||||
if($object->unitfrequency=="60"){
|
if($object->unitfrequency=="60")
|
||||||
|
{
|
||||||
$input .= ' checked="checked" />';
|
$input .= ' checked="checked" />';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
8
htdocs/custom/.gitignore
vendored
8
htdocs/custom/.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
/a*
|
/*
|
||||||
/b*
|
!.gitignore
|
||||||
/c*
|
!README.md
|
||||||
/d*
|
!index.html
|
||||||
@ -108,6 +108,8 @@ $parameters=array();
|
|||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
if ($action == 'add')
|
if ($action == 'add')
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
@ -364,7 +366,6 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl'
|
|||||||
// Build document
|
// Build document
|
||||||
else if ($action == 'builddoc') // En get ou en post
|
else if ($action == 'builddoc') // En get ou en post
|
||||||
{
|
{
|
||||||
|
|
||||||
// Save last template used to generate document
|
// Save last template used to generate document
|
||||||
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
|
|
||||||
@ -398,189 +399,24 @@ elseif ($action == 'remove_file')
|
|||||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Add file in email form
|
|
||||||
*/
|
|
||||||
if (GETPOST('addfile','alpha'))
|
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
||||||
|
|
||||||
// Set tmp user directory TODO Use a dedicated directory for temp mails files
|
|
||||||
$vardir=$conf->user->dir_output."/".$user->id;
|
|
||||||
$upload_dir_tmp = $vardir.'/temp';
|
|
||||||
|
|
||||||
dol_add_file_process($upload_dir_tmp,0,0);
|
|
||||||
$action ='presend';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remove file in email form
|
|
||||||
*/
|
|
||||||
if (GETPOST('removedfile','alpha'))
|
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
||||||
|
|
||||||
// Set tmp user directory
|
|
||||||
$vardir=$conf->user->dir_output."/".$user->id;
|
|
||||||
$upload_dir_tmp = $vardir.'/temp';
|
|
||||||
|
|
||||||
// TODO Delete only files that was uploaded from email form
|
|
||||||
dol_remove_file_process(GETPOST('removedfile','int'),0);
|
|
||||||
$action ='presend';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Send mail
|
|
||||||
*/
|
|
||||||
if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile','alpha') && ! GETPOST('cancel','alpha'))
|
|
||||||
{
|
|
||||||
$langs->load('mails');
|
|
||||||
|
|
||||||
// $ref = dol_sanitizeFileName($object->ref);
|
|
||||||
// $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf';
|
|
||||||
|
|
||||||
// if (is_readable($file))
|
|
||||||
// {
|
|
||||||
if (GETPOST('sendto','alpha'))
|
|
||||||
{
|
|
||||||
// Le destinataire a ete fourni via le champ libre
|
|
||||||
$sendto = GETPOST('sendto','alpha');
|
|
||||||
$sendtoid = 0;
|
|
||||||
}
|
|
||||||
elseif (GETPOST('receiver','alpha') != '-1')
|
|
||||||
{
|
|
||||||
// Recipient was provided from combo list
|
|
||||||
if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party
|
|
||||||
{
|
|
||||||
$sendto = $object->client->email;
|
|
||||||
$sendtoid = 0;
|
|
||||||
}
|
|
||||||
else // Id du contact
|
|
||||||
{
|
|
||||||
$sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email');
|
|
||||||
$sendtoid = GETPOST('receiver','alpha');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dol_strlen($sendto))
|
|
||||||
{
|
|
||||||
$langs->load("commercial");
|
|
||||||
|
|
||||||
$from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>';
|
|
||||||
$replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>';
|
|
||||||
$message = GETPOST('message');
|
|
||||||
$sendtocc = GETPOST('sendtocc','alpha');
|
|
||||||
$deliveryreceipt = GETPOST('deliveryreceipt','alpha');
|
|
||||||
|
|
||||||
if ($action == 'send')
|
|
||||||
{
|
|
||||||
if (dol_strlen(GETPOST('subject','alpha'))) $subject=GETPOST('subject','alpha');
|
|
||||||
else $subject = $langs->transnoentities('Shipping').' '.$object->ref;
|
|
||||||
$actiontypecode='AC_SHIP';
|
|
||||||
$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
|
|
||||||
if ($message)
|
|
||||||
{
|
|
||||||
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
|
|
||||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
|
|
||||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
|
|
||||||
$actionmsg = dol_concatdesc($actionmsg, $message);
|
|
||||||
}
|
|
||||||
$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create form object
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
|
||||||
$formmail = new FormMail($db);
|
|
||||||
|
|
||||||
$attachedfiles=$formmail->get_attached_files();
|
|
||||||
$filepath = $attachedfiles['paths'];
|
|
||||||
$filename = $attachedfiles['names'];
|
|
||||||
$mimetype = $attachedfiles['mimes'];
|
|
||||||
|
|
||||||
// Send mail
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
|
||||||
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
|
|
||||||
if ($mailfile->error)
|
|
||||||
{
|
|
||||||
$mesg='<div class="error">'.$mailfile->error.'</div>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$result=$mailfile->sendfile();
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
$error=0;
|
|
||||||
|
|
||||||
// Initialisation donnees
|
|
||||||
$object->sendtoid = $sendtoid;
|
|
||||||
$object->actiontypecode = $actiontypecode;
|
|
||||||
$object->actionmsg = $actionmsg;
|
|
||||||
$object->actionmsg2 = $actionmsg2;
|
|
||||||
$object->fk_element = $object->id;
|
|
||||||
$object->elementtype = $object->element;
|
|
||||||
|
|
||||||
// Appel des triggers
|
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
|
||||||
$interface=new Interfaces($db);
|
|
||||||
$result=$interface->run_triggers('SHIPPING_SENTBYMAIL',$object,$user,$langs,$conf);
|
|
||||||
if ($result < 0) {
|
|
||||||
$error++; $object->errors=$interface->errors;
|
|
||||||
}
|
|
||||||
// Fin appel triggers
|
|
||||||
|
|
||||||
if ($error)
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Redirect here
|
|
||||||
// This avoid sending mail twice if going out and then back to page
|
|
||||||
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
|
||||||
setEventMessage($mesg);
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$langs->load("other");
|
|
||||||
$mesg='<div class="error">';
|
|
||||||
if ($mailfile->error)
|
|
||||||
{
|
|
||||||
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
|
|
||||||
$mesg.='<br>'.$mailfile->error;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
|
|
||||||
}
|
|
||||||
$mesg.='</div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$langs->load("other");
|
|
||||||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
|
||||||
$action='presend';
|
|
||||||
dol_syslog('Recipient email is empty');
|
|
||||||
}
|
|
||||||
/* }
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
|
|
||||||
dol_syslog('Failed to read file: '.$file);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
elseif ($action == 'classifybilled')
|
elseif ($action == 'classifybilled')
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->set_billed();
|
$object->set_billed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
|
||||||
|
|
||||||
|
// Actions to send emails
|
||||||
|
if (empty($id)) $id=$facid;
|
||||||
|
$actiontypecode='AC_SHIP';
|
||||||
|
$trigger_name='SHIPPING_SENTBYMAIL';
|
||||||
|
$paramname='id';
|
||||||
|
$mode='emailfromshipment';
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
|
|||||||
@ -121,21 +121,30 @@ class Expedition extends CommonObject
|
|||||||
global $db, $langs, $conf;
|
global $db, $langs, $conf;
|
||||||
$langs->load("sendings");
|
$langs->load("sendings");
|
||||||
|
|
||||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/expedition";
|
if (!empty($conf->global->EXPEDITION_ADDON_NUMBER))
|
||||||
|
|
||||||
if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
|
|
||||||
{
|
{
|
||||||
$conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor';
|
$mybool = false;
|
||||||
}
|
|
||||||
|
|
||||||
$file = $conf->global->EXPEDITION_ADDON_NUMBER.".php";
|
$file = $conf->global->EXPEDITION_ADDON_NUMBER.".php";
|
||||||
|
|
||||||
// Chargement de la classe de numerotation
|
|
||||||
$classname = $conf->global->EXPEDITION_ADDON_NUMBER;
|
$classname = $conf->global->EXPEDITION_ADDON_NUMBER;
|
||||||
|
|
||||||
$result=include_once $dir.'/'.$file;
|
// Include file with class
|
||||||
if ($result)
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
|
|
||||||
|
foreach ($dirmodels as $reldir) {
|
||||||
|
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/expedition/");
|
||||||
|
|
||||||
|
// Load file with numbering class (if found)
|
||||||
|
$mybool|=@include_once $dir.$file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $mybool)
|
||||||
{
|
{
|
||||||
|
dol_print_error('',"Failed to include file ".$file);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$obj = new $classname();
|
$obj = new $classname();
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNextValue($soc,$this);
|
$numref = $obj->getNextValue($soc,$this);
|
||||||
|
|||||||
@ -574,25 +574,33 @@ class Fichinter extends CommonObject
|
|||||||
global $conf, $db, $langs;
|
global $conf, $db, $langs;
|
||||||
$langs->load("interventions");
|
$langs->load("interventions");
|
||||||
|
|
||||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/fichinter/";
|
|
||||||
|
|
||||||
if (! empty($conf->global->FICHEINTER_ADDON))
|
if (! empty($conf->global->FICHEINTER_ADDON))
|
||||||
{
|
{
|
||||||
$file = $conf->global->FICHEINTER_ADDON.".php";
|
$mybool = false;
|
||||||
$classname = $conf->global->FICHEINTER_ADDON;
|
|
||||||
if (! file_exists($dir.$file))
|
$file = "mod_".$conf->global->FICHEINTER_ADDON.".php";
|
||||||
{
|
$classname = "mod_".$conf->global->FICHEINTER_ADDON;
|
||||||
$file='mod_'.$file;
|
|
||||||
$classname='mod_'.$classname;
|
// Include file with class
|
||||||
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
|
|
||||||
|
foreach ($dirmodels as $reldir) {
|
||||||
|
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/fichinter/");
|
||||||
|
|
||||||
|
// Load file with numbering class (if found)
|
||||||
|
$mybool|=@include_once $dir.$file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chargement de la classe de numerotation
|
if (! $mybool)
|
||||||
require_once $dir.$file;
|
{
|
||||||
|
dol_print_error('',"Failed to include file ".$file);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$obj = new $classname();
|
$obj = new $classname();
|
||||||
|
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNumRef($soc,$this);
|
$numref = $obj->getNextValue($soc,$this);
|
||||||
|
|
||||||
if ( $numref != "")
|
if ( $numref != "")
|
||||||
{
|
{
|
||||||
@ -606,6 +614,7 @@ class Fichinter extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$langs->load("errors");
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined");
|
print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ $langs->load('companies');
|
|||||||
$langs->load('commercial');
|
$langs->load('commercial');
|
||||||
|
|
||||||
$action = GETPOST('action');
|
$action = GETPOST('action');
|
||||||
|
$cancelbutton = GETPOST('cancel');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
|
$id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
|
||||||
@ -60,10 +61,14 @@ $parameters=array('socid'=>$socid);
|
|||||||
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
if ($action == 'setsupplieraccountancycode')
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$cancelbutton = GETPOST('cancel');
|
if ($cancelbutton)
|
||||||
if (! $cancelbutton)
|
{
|
||||||
|
$action = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'setsupplieraccountancycode')
|
||||||
{
|
{
|
||||||
$result=$object->fetch($id);
|
$result=$object->fetch($id);
|
||||||
$object->code_compta_fournisseur=$_POST["supplieraccountancycode"];
|
$object->code_compta_fournisseur=$_POST["supplieraccountancycode"];
|
||||||
@ -73,8 +78,6 @@ if ($action == 'setsupplieraccountancycode')
|
|||||||
$mesg=join(',',$object->errors);
|
$mesg=join(',',$object->errors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$action="";
|
|
||||||
}
|
|
||||||
// conditions de reglement
|
// conditions de reglement
|
||||||
if ($action == 'setconditions' && $user->rights->societe->creer)
|
if ($action == 'setconditions' && $user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
@ -89,6 +92,7 @@ if ($action == 'setmode' && $user->rights->societe->creer)
|
|||||||
$result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int'));
|
$result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int'));
|
||||||
if ($result < 0) dol_print_error($db,$object->error);
|
if ($result < 0) dol_print_error($db,$object->error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -557,23 +557,32 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
global $db, $langs, $conf;
|
global $db, $langs, $conf;
|
||||||
$langs->load("orders");
|
$langs->load("orders");
|
||||||
|
|
||||||
$dir = DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/';
|
|
||||||
|
|
||||||
if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER))
|
if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER))
|
||||||
{
|
{
|
||||||
|
$mybool = false;
|
||||||
|
|
||||||
$file = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER.'.php';
|
$file = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER.'.php';
|
||||||
|
$classname=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER;
|
||||||
|
|
||||||
if (is_readable($dir.'/'.$file))
|
// Include file with class
|
||||||
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
|
|
||||||
|
foreach ($dirmodels as $reldir) {
|
||||||
|
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/supplier_order/");
|
||||||
|
|
||||||
|
// Load file with numbering class (if found)
|
||||||
|
$mybool|=@include_once $dir.$file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $mybool)
|
||||||
{
|
{
|
||||||
// Definition du nom de modele de numerotation de commande fournisseur
|
dol_print_error('',"Failed to include file ".$file);
|
||||||
$modName=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER;
|
return '';
|
||||||
require_once $dir.'/'.$file;
|
}
|
||||||
|
|
||||||
// Recuperation de la nouvelle reference
|
$obj = new $classname();
|
||||||
$objMod = new $modName($this->db);
|
$numref = $obj->getNextValue($soc,$this);
|
||||||
|
|
||||||
$numref = "";
|
|
||||||
$numref = $objMod->commande_get_num($soc,$this);
|
|
||||||
|
|
||||||
if ( $numref != "")
|
if ( $numref != "")
|
||||||
{
|
{
|
||||||
@ -581,22 +590,17 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error = $obj->error;
|
||||||
dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error);
|
dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_FailedToLoad_COMMANDE_SUPPLIER_ADDON_File",$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER);
|
$this->error = "Error_COMMANDE_SUPPLIER_ADDON_NotDefined";
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_SUPPLIER_ADDON_NotDefined");
|
|
||||||
return -3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept an order
|
* Accept an order
|
||||||
|
|||||||
@ -1514,10 +1514,14 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
|
|
||||||
$file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.".php";
|
$file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.".php";
|
||||||
$classname = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER;
|
$classname = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER;
|
||||||
|
|
||||||
// Include file with class
|
// Include file with class
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
{
|
|
||||||
$dir = $dirroot."/core/modules/supplier_invoice/";
|
foreach ($dirmodels as $reldir) {
|
||||||
|
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/supplier_invoice/");
|
||||||
|
|
||||||
// Load file with numbering class (if found)
|
// Load file with numbering class (if found)
|
||||||
$mybool|=@include_once $dir.$file;
|
$mybool|=@include_once $dir.$file;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -479,14 +479,16 @@ else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->r
|
|||||||
$result = $object->deleteline(GETPOST('lineid'));
|
$result = $object->deleteline(GETPOST('lineid'));
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$outputlangs = $langs;
|
|
||||||
if (GETPOST('lang_id'))
|
|
||||||
{
|
|
||||||
$outputlangs = new Translate("",$conf);
|
|
||||||
$outputlangs->setDefaultLang(GETPOST('lang_id'));
|
|
||||||
}
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
{
|
{
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang = '';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||||
|
if (! empty($newlang)) {
|
||||||
|
$outputlangs = new Translate("", $conf);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
$ret=$object->fetch($object->id); // Reload to get new records
|
$ret=$object->fetch($object->id); // Reload to get new records
|
||||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
}
|
}
|
||||||
@ -571,6 +573,14 @@ else if ($action == 'confirm_approve' && $confirm == 'yes' && $user->rights->fou
|
|||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang = '';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||||
|
if (! empty($newlang)) {
|
||||||
|
$outputlangs = new Translate("", $conf);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
}
|
}
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
|
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
|
||||||
|
|||||||
@ -66,15 +66,18 @@ if ($user->societe_id > 0)
|
|||||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
$hookmanager->initHooks(array('paymentsupplier'));
|
$hookmanager->initHooks(array('paymentsupplier'));
|
||||||
|
|
||||||
$parameters=array('socid'=>$socid);
|
|
||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$parameters=array('socid'=>$socid);
|
||||||
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
|
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
|
||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
@ -227,7 +230,7 @@ if ($action == 'confirm_paiement' && $confirm == 'yes')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker: */
|
|
||||||
/* @(#) $Header: /sources/phpprintipp/phpprintipp/php_classes/BasicIPP.php,v 1.6 2010/08/22 15:45:17 harding Exp $
|
/* @(#) $Header: /sources/phpprintipp/phpprintipp/php_classes/BasicIPP.php,v 1.7 2012/03/01 17:21:04 harding Exp $
|
||||||
*
|
*
|
||||||
* Class BasicIPP - Send Basic IPP requests, Get and parses IPP Responses.
|
* Class BasicIPP - Send Basic IPP requests, Get and parses IPP Responses.
|
||||||
*
|
*
|
||||||
@ -35,103 +35,26 @@
|
|||||||
- RFC 3380
|
- RFC 3380
|
||||||
- RFC 3382
|
- RFC 3382
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
TODO: beta tests on other servers than Cups
|
|
||||||
*/
|
|
||||||
// required and included files
|
|
||||||
require_once ("http_class.php");
|
require_once ("http_class.php");
|
||||||
/*
|
|
||||||
// If you want http backend from http://www.phpclasses.org/browse/package/3.html
|
class ippException extends \Exception
|
||||||
require_once("HTTP/http.php");
|
|
||||||
include_once("SASL/sasl.php");
|
|
||||||
include_once("SASL/basic_sasl_client.php");
|
|
||||||
include_once("SASL/digest_sasl_client.php");
|
|
||||||
include_once("SASL/ntlm_sasl_client.php");
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Class and Function List:
|
|
||||||
* Function list:
|
|
||||||
* - __construct()
|
|
||||||
* - getErrorFormatted()
|
|
||||||
* - getErrno()
|
|
||||||
* - setPort()
|
|
||||||
* - setUnix()
|
|
||||||
* - setHost()
|
|
||||||
* - setTimeout()
|
|
||||||
* - setPrinterURI()
|
|
||||||
* - setData()
|
|
||||||
* - setRawText()
|
|
||||||
* - unsetRawText()
|
|
||||||
* - setBinary()
|
|
||||||
* - setFormFeed()
|
|
||||||
* - unsetFormFeed()
|
|
||||||
* - setCharset()
|
|
||||||
* - setLanguage()
|
|
||||||
* - setDocumentFormat()
|
|
||||||
* - setMimeMediaType()
|
|
||||||
* - setCopies()
|
|
||||||
* - setDocumentName()
|
|
||||||
* - setJobName()
|
|
||||||
* - setUserName()
|
|
||||||
* - setAuthentification()
|
|
||||||
* - setAuthentication()
|
|
||||||
* - setSides()
|
|
||||||
* - setFidelity()
|
|
||||||
* - unsetFidelity()
|
|
||||||
* - setMessage()
|
|
||||||
* - setPageRanges()
|
|
||||||
* - setAttribute()
|
|
||||||
* - unsetAttribute()
|
|
||||||
* - setLog()
|
|
||||||
* - printDebug()
|
|
||||||
* - getDebug()
|
|
||||||
* - printJob()
|
|
||||||
* - _sendHttp()
|
|
||||||
* - _initTags()
|
|
||||||
* - _setOperationId()
|
|
||||||
* - _setJobId()
|
|
||||||
* - _setJobUri()
|
|
||||||
* - _parseServerOutput()
|
|
||||||
* - _parseHttpHeaders()
|
|
||||||
* - _parseIppVersion()
|
|
||||||
* - _parseStatusCode()
|
|
||||||
* - _parseRequestID()
|
|
||||||
* - _interpretInteger()
|
|
||||||
* - _parseResponse()
|
|
||||||
* - _stringJob()
|
|
||||||
* - _buildValues()
|
|
||||||
* - _giveMeStringLength()
|
|
||||||
* - _enumBuild()
|
|
||||||
* - _integerBuild()
|
|
||||||
* - _rangeOfIntegerBuild()
|
|
||||||
* - _setJobAttribute()
|
|
||||||
* - _setOperationAttribute()
|
|
||||||
* - _setPrinterAttribute()
|
|
||||||
* - _putDebug()
|
|
||||||
* - _errorLog()
|
|
||||||
* Classes list:
|
|
||||||
* - ippException extends Exception
|
|
||||||
* - BasicIPP
|
|
||||||
*/
|
|
||||||
/***********************
|
|
||||||
*
|
|
||||||
* ippException class
|
|
||||||
*
|
|
||||||
************************/
|
|
||||||
class ippException extends Exception
|
|
||||||
{
|
{
|
||||||
protected $errno;
|
protected $errno;
|
||||||
|
|
||||||
public function __construct($msg, $errno = null)
|
public function __construct($msg, $errno = null)
|
||||||
{
|
{
|
||||||
parent::__construct($msg);
|
parent::__construct($msg);
|
||||||
$this->errno = $errno;
|
$this->errno = $errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getErrorFormatted()
|
public function getErrorFormatted()
|
||||||
{
|
{
|
||||||
$return = sprintf("[ipp]: %s -- " . _(" file %s, line %s"),
|
$return = sprintf("[ipp]: %s -- " . _(" file %s, line %s"),
|
||||||
$this->getMessage() , $this->getFile() , $this->getLine());
|
$this->getMessage() , $this->getFile() , $this->getLine());
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getErrno()
|
public function getErrno()
|
||||||
{
|
{
|
||||||
return $this->errno;
|
return $this->errno;
|
||||||
@ -140,12 +63,6 @@ class ippException extends Exception
|
|||||||
|
|
||||||
class BasicIPP
|
class BasicIPP
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// variables declaration
|
|
||||||
//
|
|
||||||
|
|
||||||
// setup variables
|
|
||||||
|
|
||||||
public $paths = array(
|
public $paths = array(
|
||||||
"root" => "/",
|
"root" => "/",
|
||||||
"admin" => "/admin/",
|
"admin" => "/admin/",
|
||||||
@ -161,7 +78,6 @@ class BasicIPP
|
|||||||
public $handle_http_exceptions = 1;
|
public $handle_http_exceptions = 1;
|
||||||
|
|
||||||
// readables variables
|
// readables variables
|
||||||
|
|
||||||
public $jobs = array();
|
public $jobs = array();
|
||||||
public $jobs_uri = array();
|
public $jobs_uri = array();
|
||||||
public $status = array();
|
public $status = array();
|
||||||
@ -172,9 +88,11 @@ class BasicIPP
|
|||||||
public $job_attributes; // object you can read: last job attributes
|
public $job_attributes; // object you can read: last job attributes
|
||||||
public $jobs_attributes; // object you can read: jobs attributes after getJobs()
|
public $jobs_attributes; // object you can read: jobs attributes after getJobs()
|
||||||
public $available_printers = array();
|
public $available_printers = array();
|
||||||
|
public $printer_map = array();
|
||||||
public $printers_uri = array();
|
public $printers_uri = array();
|
||||||
public $debug = array();
|
public $debug = array();
|
||||||
public $response;
|
public $response;
|
||||||
|
public $meta;
|
||||||
|
|
||||||
// protected variables;
|
// protected variables;
|
||||||
protected $log_level = 2; // max 3: very verbose
|
protected $log_level = 2; // max 3: very verbose
|
||||||
@ -193,6 +111,7 @@ class BasicIPP
|
|||||||
protected $stream;
|
protected $stream;
|
||||||
protected $host = "localhost";
|
protected $host = "localhost";
|
||||||
protected $port = "631";
|
protected $port = "631";
|
||||||
|
protected $requesting_user = '';
|
||||||
protected $printer_uri;
|
protected $printer_uri;
|
||||||
protected $timeout = "20"; //20 secs
|
protected $timeout = "20"; //20 secs
|
||||||
protected $errNo;
|
protected $errNo;
|
||||||
@ -200,7 +119,6 @@ class BasicIPP
|
|||||||
protected $datatype;
|
protected $datatype;
|
||||||
protected $datahead;
|
protected $datahead;
|
||||||
protected $datatail;
|
protected $datatail;
|
||||||
public $meta;
|
|
||||||
protected $operation_id;
|
protected $operation_id;
|
||||||
protected $delay;
|
protected $delay;
|
||||||
protected $error_generation; //devel feature
|
protected $error_generation; //devel feature
|
||||||
@ -216,31 +134,25 @@ class BasicIPP
|
|||||||
protected $end_collection = false; //RFC3382
|
protected $end_collection = false; //RFC3382
|
||||||
protected $collection_nbr = array(); //RFC3382
|
protected $collection_nbr = array(); //RFC3382
|
||||||
protected $unix = false; // true -> use unix sockets instead of http
|
protected $unix = false; // true -> use unix sockets instead of http
|
||||||
|
protected $output;
|
||||||
|
|
||||||
// constructor
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$tz = getenv("date.timezone");
|
$tz = getenv("date.timezone");
|
||||||
if (!$tz) $tz = @date_default_timezone_get();
|
if (!$tz)
|
||||||
date_default_timezone_set($tz);
|
{
|
||||||
$this->meta = new stdClass();
|
$tz = @date_default_timezone_get();
|
||||||
$this->setup = new stdClass();
|
|
||||||
$this->values = new stdClass();
|
|
||||||
$this->serveroutput = new stdClass();
|
|
||||||
$this->error_generation = new stdClass();
|
|
||||||
$this->_parsing = new stdClass();
|
|
||||||
self::_initTags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************
|
date_default_timezone_set($tz);
|
||||||
*
|
$this->meta = new \stdClass();
|
||||||
* PUBLIC FUNCTIONS
|
$this->setup = new \stdClass();
|
||||||
*
|
$this->values = new \stdClass();
|
||||||
*******************/
|
$this->serveroutput = new \stdClass();
|
||||||
|
$this->error_generation = new \stdClass();
|
||||||
//
|
$this->_parsing = new \stdClass();
|
||||||
// SETUP
|
self::_initTags();
|
||||||
//
|
}
|
||||||
|
|
||||||
public function setPort($port = '631')
|
public function setPort($port = '631')
|
||||||
{
|
{
|
||||||
@ -303,7 +215,12 @@ class BasicIPP
|
|||||||
{
|
{
|
||||||
$output = $this->data;
|
$output = $this->data;
|
||||||
}
|
}
|
||||||
if (substr($output, -1, 1) != chr(0x0c)) if (!isset($this->setup->noFormFeed)) $this->datatail = chr(0x0c);
|
if (substr($output, -1, 1) != chr(0x0c)) {
|
||||||
|
if (!isset($this->setup->noFormFeed))
|
||||||
|
{
|
||||||
|
$this->datatail = chr(0x0c);
|
||||||
|
}
|
||||||
|
}
|
||||||
self::_putDebug(_("Forcing data to be interpreted as RAW TEXT") , 2);
|
self::_putDebug(_("Forcing data to be interpreted as RAW TEXT") , 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +249,7 @@ class BasicIPP
|
|||||||
$this->setup->noFormFeed = 1;
|
$this->setup->noFormFeed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCharset($charset = 'us-ascii')
|
public function setCharset($charset = 'utf-8')
|
||||||
{
|
{
|
||||||
$charset = strtolower($charset);
|
$charset = strtolower($charset);
|
||||||
$this->charset = $charset;
|
$this->charset = $charset;
|
||||||
@ -378,7 +295,12 @@ class BasicIPP
|
|||||||
public function setCopies($nbrcopies = 1)
|
public function setCopies($nbrcopies = 1)
|
||||||
{
|
{
|
||||||
$this->meta->copies = "";
|
$this->meta->copies = "";
|
||||||
if ($nbrcopies == 1 || !$nbrcopies) return true;
|
|
||||||
|
if ($nbrcopies == 1 || !$nbrcopies)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$copies = self::_integerBuild($nbrcopies);
|
$copies = self::_integerBuild($nbrcopies);
|
||||||
$this->meta->copies = chr(0x21) // integer type | value-tag
|
$this->meta->copies = chr(0x21) // integer type | value-tag
|
||||||
. chr(0x00) . chr(0x06) // name-length
|
. chr(0x00) . chr(0x06) // name-length
|
||||||
@ -392,7 +314,9 @@ class BasicIPP
|
|||||||
public function setDocumentName($document_name = "")
|
public function setDocumentName($document_name = "")
|
||||||
{
|
{
|
||||||
$this->meta->document_name = "";
|
$this->meta->document_name = "";
|
||||||
if (!$document_name) return true;
|
if (!$document_name) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
$document_name = substr($document_name, 0, 1023);
|
$document_name = substr($document_name, 0, 1023);
|
||||||
$length = strlen($document_name);
|
$length = strlen($document_name);
|
||||||
$length = chr($length);
|
$length = chr($length);
|
||||||
@ -414,7 +338,9 @@ class BasicIPP
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$postpend = date('-H:i:s-') . $this->_setJobId();
|
$postpend = date('-H:i:s-') . $this->_setJobId();
|
||||||
if ($absolute) $postpend = '';
|
if ($absolute) {
|
||||||
|
$postpend = '';
|
||||||
|
}
|
||||||
if (isset($this->values->jobname) && $jobname == '(PHP)')
|
if (isset($this->values->jobname) && $jobname == '(PHP)')
|
||||||
{
|
{
|
||||||
$jobname = $this->values->jobname;
|
$jobname = $this->values->jobname;
|
||||||
@ -434,8 +360,12 @@ class BasicIPP
|
|||||||
{
|
{
|
||||||
$this->requesting_user = $username;
|
$this->requesting_user = $username;
|
||||||
$this->meta->username = '';
|
$this->meta->username = '';
|
||||||
if (!$username) return true;
|
if (!$username) {
|
||||||
if ($username == 'PHP-SERVER' && isset($this->meta->username)) return TRUE;
|
return true;
|
||||||
|
}
|
||||||
|
if ($username == 'PHP-SERVER' && isset($this->meta->username)) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
$value_length = 0x00;
|
$value_length = 0x00;
|
||||||
for ($i = 0; $i < strlen($username); $i++)
|
for ($i = 0; $i < strlen($username); $i++)
|
||||||
@ -470,7 +400,11 @@ class BasicIPP
|
|||||||
public function setSides($sides = 2)
|
public function setSides($sides = 2)
|
||||||
{
|
{
|
||||||
$this->meta->sides = '';
|
$this->meta->sides = '';
|
||||||
if (!$sides) return true;
|
if (!$sides)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($sides)
|
switch ($sides)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -484,11 +418,8 @@ class BasicIPP
|
|||||||
case "2CE":
|
case "2CE":
|
||||||
$sides = "two-sided-short-edge";
|
$sides = "two-sided-short-edge";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
$sides = $sides; // yeah, what ?
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->meta->sides = chr(0x44) // keyword type | value-tag
|
$this->meta->sides = chr(0x44) // keyword type | value-tag
|
||||||
. chr(0x00) . chr(0x05) // name-length
|
. chr(0x00) . chr(0x05) // name-length
|
||||||
. "sides" // sides | name
|
. "sides" // sides | name
|
||||||
@ -526,7 +457,9 @@ class BasicIPP
|
|||||||
public function setMessage($message = '')
|
public function setMessage($message = '')
|
||||||
{
|
{
|
||||||
$this->meta->message = '';
|
$this->meta->message = '';
|
||||||
if (!$message) return true;
|
if (!$message) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
$this->meta->message =
|
$this->meta->message =
|
||||||
chr(0x41) // attribute type = textWithoutLanguage
|
chr(0x41) // attribute type = textWithoutLanguage
|
||||||
. chr(0x00)
|
. chr(0x00)
|
||||||
@ -542,7 +475,9 @@ class BasicIPP
|
|||||||
// $pages_ranges = string: "1:5 10:25 40:52 ..."
|
// $pages_ranges = string: "1:5 10:25 40:52 ..."
|
||||||
// to unset, specify an empty string.
|
// to unset, specify an empty string.
|
||||||
$this->meta->page_range = '';
|
$this->meta->page_range = '';
|
||||||
if (!$page_ranges) return true;
|
if (!$page_ranges) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
$page_ranges = trim(str_replace("-", ":", $page_ranges));
|
$page_ranges = trim(str_replace("-", ":", $page_ranges));
|
||||||
$first = true;
|
$first = true;
|
||||||
#$page_ranges = split(' ', $page_ranges);
|
#$page_ranges = split(' ', $page_ranges);
|
||||||
@ -679,13 +614,21 @@ class BasicIPP
|
|||||||
//
|
//
|
||||||
// LOGGING / DEBUGGING
|
// LOGGING / DEBUGGING
|
||||||
//
|
//
|
||||||
|
/**
|
||||||
|
* Sets log file destination. Creates the file if has permission.
|
||||||
|
*
|
||||||
|
* @param string $log_destination
|
||||||
|
* @param string $destination_type
|
||||||
|
* @param int $level
|
||||||
|
*
|
||||||
|
* @throws ippException
|
||||||
|
*/
|
||||||
public function setLog($log_destination, $destination_type = 'file', $level = 2)
|
public function setLog($log_destination, $destination_type = 'file', $level = 2)
|
||||||
{
|
{
|
||||||
|
if (!file_exists($log_destination) && is_writable(dirname($log_destination)))
|
||||||
if (is_string($log_destination) && !empty($log_destination))
|
|
||||||
{
|
{
|
||||||
$this->log_destination = $log_destination;
|
touch($log_destination);
|
||||||
|
chmod($log_destination, 0777);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($destination_type)
|
switch ($destination_type)
|
||||||
@ -736,7 +679,6 @@ class BasicIPP
|
|||||||
//
|
//
|
||||||
// OPERATIONS
|
// OPERATIONS
|
||||||
//
|
//
|
||||||
|
|
||||||
public function printJob()
|
public function printJob()
|
||||||
{
|
{
|
||||||
// this BASIC version of printJob do not parse server
|
// this BASIC version of printJob do not parse server
|
||||||
@ -747,7 +689,9 @@ class BasicIPP
|
|||||||
date('Y-m-d H:i:s')
|
date('Y-m-d H:i:s')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (!$this->_stringJob()) return FALSE;
|
if (!$this->_stringJob()) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
if (is_readable($this->data))
|
if (is_readable($this->data))
|
||||||
{
|
{
|
||||||
self::_putDebug(_("Printing a FILE"));
|
self::_putDebug(_("Printing a FILE"));
|
||||||
@ -821,17 +765,9 @@ class BasicIPP
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************
|
|
||||||
*
|
|
||||||
* PROTECTED FUNCTIONS
|
|
||||||
*
|
|
||||||
*******************/
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// HTTP OUTPUT
|
// HTTP OUTPUT
|
||||||
//
|
//
|
||||||
|
|
||||||
protected function _sendHttp($post_values, $uri)
|
protected function _sendHttp($post_values, $uri)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -843,8 +779,12 @@ class BasicIPP
|
|||||||
$this->serveroutput->headers = array();
|
$this->serveroutput->headers = array();
|
||||||
$this->serveroutput->body = "";
|
$this->serveroutput->body = "";
|
||||||
$http = new http_class;
|
$http = new http_class;
|
||||||
if (!$this->unix) $http->host = $this->host;
|
if (!$this->unix) {
|
||||||
else $http->host = "localhost";
|
$http->host = $this->host;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$http->host = "localhost";
|
||||||
|
}
|
||||||
$http->with_exceptions = $this->with_exceptions;
|
$http->with_exceptions = $this->with_exceptions;
|
||||||
if ($this->debug_http)
|
if ($this->debug_http)
|
||||||
{
|
{
|
||||||
@ -857,8 +797,12 @@ class BasicIPP
|
|||||||
$http->html_debug = 0;
|
$http->html_debug = 0;
|
||||||
}
|
}
|
||||||
$url = "http://" . $this->host;
|
$url = "http://" . $this->host;
|
||||||
if ($this->ssl) $url = "https://" . $this->host;
|
if ($this->ssl) {
|
||||||
if ($this->unix) $url = "unix://" . $this->host;
|
$url = "https://" . $this->host;
|
||||||
|
}
|
||||||
|
if ($this->unix) {
|
||||||
|
$url = "unix://" . $this->host;
|
||||||
|
}
|
||||||
$http->port = $this->port;
|
$http->port = $this->port;
|
||||||
$http->timeout = $this->http_timeout;
|
$http->timeout = $this->http_timeout;
|
||||||
$http->data_timeout = $this->http_data_timeout;
|
$http->data_timeout = $this->http_data_timeout;
|
||||||
@ -875,11 +819,14 @@ class BasicIPP
|
|||||||
"Data" => $post_values["Data"]
|
"Data" => $post_values["Data"]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (isset($post_values["File"])) $arguments["BodyStream"][] = array(
|
if (isset($post_values["File"])) {
|
||||||
|
$arguments["BodyStream"][] = array(
|
||||||
"File" => $post_values["File"]
|
"File" => $post_values["File"]
|
||||||
);
|
);
|
||||||
|
}
|
||||||
if (isset($post_values["FileType"])
|
if (isset($post_values["FileType"])
|
||||||
&& !strcmp($post_values["FileType"], "TEXT"))
|
&& !strcmp($post_values["FileType"], "TEXT")
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$arguments["BodyStream"][] = array("Data" => Chr(12));
|
$arguments["BodyStream"][] = array("Data" => Chr(12));
|
||||||
}
|
}
|
||||||
@ -963,7 +910,9 @@ class BasicIPP
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
$http->ReadReplyBody($body, 1024);
|
$http->ReadReplyBody($body, 1024);
|
||||||
if (strlen($body) == 0) break;
|
if (strlen($body) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
self::_putDebug(htmlentities($body));
|
self::_putDebug(htmlentities($body));
|
||||||
$this->serveroutput->body.= $body;
|
$this->serveroutput->body.= $body;
|
||||||
@ -978,7 +927,6 @@ class BasicIPP
|
|||||||
//
|
//
|
||||||
// INIT
|
// INIT
|
||||||
//
|
//
|
||||||
|
|
||||||
protected function _initTags()
|
protected function _initTags()
|
||||||
{
|
{
|
||||||
$this->tags_types = array(
|
$this->tags_types = array(
|
||||||
@ -1142,7 +1090,6 @@ class BasicIPP
|
|||||||
//
|
//
|
||||||
// SETUP
|
// SETUP
|
||||||
//
|
//
|
||||||
|
|
||||||
protected function _setOperationId()
|
protected function _setOperationId()
|
||||||
{
|
{
|
||||||
$prepend = '';
|
$prepend = '';
|
||||||
@ -1156,7 +1103,9 @@ class BasicIPP
|
|||||||
$this->meta->jobid+= 1;
|
$this->meta->jobid+= 1;
|
||||||
$prepend = '';
|
$prepend = '';
|
||||||
$prepend_length = 4 - strlen($this->meta->jobid);
|
$prepend_length = 4 - strlen($this->meta->jobid);
|
||||||
for ($i = 0; $i < $prepend_length; $i++) $prepend.= '0';
|
for ($i = 0; $i < $prepend_length; $i++) {
|
||||||
|
$prepend.= '0';
|
||||||
|
}
|
||||||
return $prepend . $this->meta->jobid;
|
return $prepend . $this->meta->jobid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1173,11 +1122,12 @@ class BasicIPP
|
|||||||
//
|
//
|
||||||
// RESPONSE PARSING
|
// RESPONSE PARSING
|
||||||
//
|
//
|
||||||
|
|
||||||
protected function _parseServerOutput()
|
protected function _parseServerOutput()
|
||||||
{
|
{
|
||||||
$this->serveroutput->response = array();
|
$this->serveroutput->response = array();
|
||||||
if (!self::_parseHttpHeaders()) return FALSE;
|
if (!self::_parseHttpHeaders()) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$this->_parsing->offset = 0;
|
$this->_parsing->offset = 0;
|
||||||
self::_parseIppVersion();
|
self::_parseIppVersion();
|
||||||
self::_parseStatusCode();
|
self::_parseStatusCode();
|
||||||
@ -1480,7 +1430,6 @@ class BasicIPP
|
|||||||
*
|
*
|
||||||
ord($value[strlen($value) - $i])
|
ord($value[strlen($value) - $i])
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($value_parsed >= 2147483648)
|
if ($value_parsed >= 2147483648)
|
||||||
{
|
{
|
||||||
@ -1496,11 +1445,14 @@ class BasicIPP
|
|||||||
//
|
//
|
||||||
// REQUEST BUILDING
|
// REQUEST BUILDING
|
||||||
//
|
//
|
||||||
|
|
||||||
protected function _stringJob()
|
protected function _stringJob()
|
||||||
{
|
{
|
||||||
if (!isset($this->setup->charset)) self::setCharset('us-ascii');
|
if (!isset($this->setup->charset)) {
|
||||||
if (!isset($this->setup->datatype)) self::setBinary();
|
self::setCharset();
|
||||||
|
}
|
||||||
|
if (!isset($this->setup->datatype)) {
|
||||||
|
self::setBinary();
|
||||||
|
}
|
||||||
if (!isset($this->setup->uri))
|
if (!isset($this->setup->uri))
|
||||||
{
|
{
|
||||||
$this->getPrinters();
|
$this->getPrinters();
|
||||||
@ -1521,16 +1473,34 @@ class BasicIPP
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isset($this->setup->copies)) self::setCopies(1);
|
if (!isset($this->setup->copies)) {
|
||||||
if (!isset($this->setup->language)) self::setLanguage('en_us');
|
self::setCopies(1);
|
||||||
if (!isset($this->setup->mime_media_type)) self::setMimeMediaType();
|
}
|
||||||
if (!isset($this->setup->jobname)) self::setJobName();
|
if (!isset($this->setup->language)) {
|
||||||
|
self::setLanguage('en_us');
|
||||||
|
}
|
||||||
|
if (!isset($this->setup->mime_media_type)) {
|
||||||
|
self::setMimeMediaType();
|
||||||
|
}
|
||||||
|
if (!isset($this->setup->jobname)) {
|
||||||
|
self::setJobName();
|
||||||
|
}
|
||||||
unset($this->setup->jobname);
|
unset($this->setup->jobname);
|
||||||
if (!isset($this->meta->username)) self::setUserName();
|
if (!isset($this->meta->username)) {
|
||||||
if (!isset($this->meta->fidelity)) $this->meta->fidelity = '';
|
self::setUserName();
|
||||||
if (!isset($this->meta->document_name)) $this->meta->document_name = '';
|
}
|
||||||
if (!isset($this->meta->sides)) $this->meta->sides = '';
|
if (!isset($this->meta->fidelity)) {
|
||||||
if (!isset($this->meta->page_ranges)) $this->meta->page_ranges = '';
|
$this->meta->fidelity = '';
|
||||||
|
}
|
||||||
|
if (!isset($this->meta->document_name)) {
|
||||||
|
$this->meta->document_name = '';
|
||||||
|
}
|
||||||
|
if (!isset($this->meta->sides)) {
|
||||||
|
$this->meta->sides = '';
|
||||||
|
}
|
||||||
|
if (!isset($this->meta->page_ranges)) {
|
||||||
|
$this->meta->page_ranges = '';
|
||||||
|
}
|
||||||
$jobattributes = '';
|
$jobattributes = '';
|
||||||
$operationattributes = '';
|
$operationattributes = '';
|
||||||
$printerattributes = '';
|
$printerattributes = '';
|
||||||
@ -1560,8 +1530,7 @@ class BasicIPP
|
|||||||
. $this->meta->copies
|
. $this->meta->copies
|
||||||
. $this->meta->sides
|
. $this->meta->sides
|
||||||
. $this->meta->page_ranges
|
. $this->meta->page_ranges
|
||||||
. $jobattributes
|
. $jobattributes;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
$this->stringjob.= chr(0x03); // end-of-attributes | end-of-attributes-tag
|
$this->stringjob.= chr(0x03); // end-of-attributes | end-of-attributes-tag
|
||||||
self::_putDebug(
|
self::_putDebug(
|
||||||
@ -1841,8 +1810,12 @@ class BasicIPP
|
|||||||
$value-= $int3;
|
$value-= $int3;
|
||||||
$value = $value >> 8;
|
$value = $value >> 8;
|
||||||
$int4 = $value & 0xFF; //64bits
|
$int4 = $value & 0xFF; //64bits
|
||||||
if ($initial_value < 0) $int4 = chr($int4) | chr(0x80);
|
if ($initial_value < 0) {
|
||||||
else $int4 = chr($int4);
|
$int4 = chr($int4) | chr(0x80);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$int4 = chr($int4);
|
||||||
|
}
|
||||||
$value = $int4 . chr($int3) . chr($int2) . chr($int1);
|
$value = $int4 . chr($int3) . chr($int2) . chr($int1);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
@ -1851,7 +1824,9 @@ class BasicIPP
|
|||||||
{
|
{
|
||||||
#$integers = split(":", $integers);
|
#$integers = split(":", $integers);
|
||||||
$integers = preg_split("#:#", $integers);
|
$integers = preg_split("#:#", $integers);
|
||||||
for ($i = 0; $i < 2; $i++) $outvalue[$i] = self::_integerBuild($integers[$i]);
|
for ($i = 0; $i < 2; $i++) {
|
||||||
|
$outvalue[$i] = self::_integerBuild($integers[$i]);
|
||||||
|
}
|
||||||
return $outvalue[0] . $outvalue[1];
|
return $outvalue[0] . $outvalue[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1865,6 +1840,7 @@ class BasicIPP
|
|||||||
$this->job_tags[$attribute]['value'][] = self::_integerBuild($value);
|
$this->job_tags[$attribute]['value'][] = self::_integerBuild($value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'boolean':
|
||||||
case 'nameWithoutLanguage':
|
case 'nameWithoutLanguage':
|
||||||
case 'nameWithLanguage':
|
case 'nameWithLanguage':
|
||||||
case 'textWithoutLanguage':
|
case 'textWithoutLanguage':
|
||||||
@ -1885,8 +1861,12 @@ class BasicIPP
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'resolution':
|
case 'resolution':
|
||||||
if (preg_match("#dpi#", $value)) $unit = chr(0x3);
|
if (preg_match("#dpi#", $value)) {
|
||||||
if (preg_match("#dpc#", $value)) $unit = chr(0x4);
|
$unit = chr(0x3);
|
||||||
|
}
|
||||||
|
if (preg_match("#dpc#", $value)) {
|
||||||
|
$unit = chr(0x4);
|
||||||
|
}
|
||||||
$search = array(
|
$search = array(
|
||||||
"#(dpi|dpc)#",
|
"#(dpi|dpc)#",
|
||||||
'#(x|-)#'
|
'#(x|-)#'
|
||||||
@ -1964,8 +1944,14 @@ class BasicIPP
|
|||||||
//
|
//
|
||||||
protected function _putDebug($string, $level = 1)
|
protected function _putDebug($string, $level = 1)
|
||||||
{
|
{
|
||||||
if ($level === false) return;
|
if ($level === false) {
|
||||||
if ($level < $this->debug_level) return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($level < $this->debug_level) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->debug[$this->debug_count] = substr($string, 0, 1024);
|
$this->debug[$this->debug_count] = substr($string, 0, 1024);
|
||||||
$this->debug_count++;
|
$this->debug_count++;
|
||||||
//$this->debug .= substr($string,0,1024);
|
//$this->debug .= substr($string,0,1024);
|
||||||
@ -1977,24 +1963,20 @@ class BasicIPP
|
|||||||
//
|
//
|
||||||
protected function _errorLog($string_to_log, $level)
|
protected function _errorLog($string_to_log, $level)
|
||||||
{
|
{
|
||||||
if ($level < $this->log_level) return;
|
if ($level > $this->log_level) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$string = sprintf('%s : %s:%s user %s : %s', basename($_SERVER['PHP_SELF']) , $this->host, $this->port, $this->requesting_user, $string_to_log);
|
$string = sprintf('%s : %s:%s user %s : %s', basename($_SERVER['PHP_SELF']) , $this->host, $this->port, $this->requesting_user, $string_to_log);
|
||||||
|
|
||||||
if ($this->log_type == 0)
|
if ($this->log_type == 0)
|
||||||
{
|
{
|
||||||
error_log($string);
|
error_log($string);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$string = sprintf("%s %s Host %s:%s user %s : %s\n", date('M d H:i:s') , basename($_SERVER['PHP_SELF']) , $this->host, $this->port, $this->requesting_user, $string_to_log);
|
$string = sprintf("%s %s Host %s:%s user %s : %s\n", date('M d H:i:s') , basename($_SERVER['PHP_SELF']) , $this->host, $this->port, $this->requesting_user, $string_to_log);
|
||||||
error_log($string, $this->log_type, $this->log_destination);
|
error_log($string, $this->log_type, $this->log_destination);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
|
||||||
/*
|
|
||||||
* Local variables:
|
|
||||||
* mode: php
|
|
||||||
* tab-width: 4
|
|
||||||
* c-basic-offset: 4
|
|
||||||
* End:
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
|
|
||||||
/* @(#) $Header: /sources/phpprintipp/phpprintipp/php_classes/CupsPrintIPP.php,v 1.1 2008/06/21 00:30:56 harding Exp $
|
/* @(#) $Header: /sources/phpprintipp/phpprintipp/php_classes/CupsPrintIPP.php,v 1.1 2008/06/21 00:30:56 harding Exp $
|
||||||
*
|
*
|
||||||
* Class PrintIPP - Send extended IPP requests.
|
* Class PrintIPP - Send extended IPP requests.
|
||||||
@ -26,7 +26,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This class is intended to implement Internet Printing Protocol on client side.
|
This class is intended to implement Internet Printing Protocol on client side.
|
||||||
|
|
||||||
References needed to debug / add functionnalities:
|
References needed to debug / add functionnalities:
|
||||||
@ -39,28 +38,25 @@
|
|||||||
|
|
||||||
require_once("ExtendedPrintIPP.php");
|
require_once("ExtendedPrintIPP.php");
|
||||||
|
|
||||||
class CupsPrintIPP extends ExtendedPrintIPP {
|
class CupsPrintIPP extends ExtendedPrintIPP
|
||||||
|
{
|
||||||
// {{{ variables declaration
|
|
||||||
|
|
||||||
public $printers_attributes;
|
public $printers_attributes;
|
||||||
public $defaults_attributes;
|
public $defaults_attributes;
|
||||||
|
|
||||||
// }}}
|
protected $parsed;
|
||||||
|
protected $output;
|
||||||
|
|
||||||
// {{{ constructor
|
public function __construct()
|
||||||
public function __construct() {
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
self::_initTags();
|
self::_initTags();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// OPERATIONS
|
// OPERATIONS
|
||||||
//
|
//
|
||||||
|
public function cupsGetDefaults($attributes=array("all"))
|
||||||
// {{{ cupsGetDefaults ($attributes="all")
|
{
|
||||||
public function cupsGetDefaults($attributes=array("all")) {
|
|
||||||
//The CUPS-Get-Default operation returns the default printer URI and attributes
|
//The CUPS-Get-Default operation returns the default printer URI and attributes
|
||||||
|
|
||||||
$this->jobs = array_merge($this->jobs,array(""));
|
$this->jobs = array_merge($this->jobs,array(""));
|
||||||
@ -69,25 +65,35 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
unset($this->printer_attributes);
|
unset($this->printer_attributes);
|
||||||
|
|
||||||
if (!isset($this->setup->charset))
|
if (!isset($this->setup->charset))
|
||||||
self::setCharset('us-ascii');
|
{
|
||||||
|
self::setCharset();
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($this->setup->language))
|
if (!isset($this->setup->language))
|
||||||
|
{
|
||||||
self::setLanguage('en');
|
self::setLanguage('en');
|
||||||
|
}
|
||||||
|
|
||||||
self::_setOperationId();
|
self::_setOperationId();
|
||||||
|
|
||||||
for($i = 0 ; $i < count($attributes) ; $i++)
|
for($i = 0 ; $i < count($attributes) ; $i++)
|
||||||
|
{
|
||||||
if ($i == 0)
|
if ($i == 0)
|
||||||
|
{
|
||||||
$this->meta->attributes = chr(0x44) // Keyword
|
$this->meta->attributes = chr(0x44) // Keyword
|
||||||
. self::_giveMeStringLength('requested-attributes')
|
. self::_giveMeStringLength('requested-attributes')
|
||||||
. 'requested-attributes'
|
. 'requested-attributes'
|
||||||
. self::_giveMeStringLength($attributes[0])
|
. self::_giveMeStringLength($attributes[0])
|
||||||
. $attributes[0];
|
. $attributes[0];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$this->meta->attributes .= chr(0x44) // Keyword
|
$this->meta->attributes .= chr(0x44) // Keyword
|
||||||
. chr(0x0).chr(0x0) // zero-length name
|
. chr(0x0).chr(0x0) // zero-length name
|
||||||
. self::_giveMeStringLength($attributes[$i])
|
. self::_giveMeStringLength($attributes[$i])
|
||||||
. $attributes[$i];
|
. $attributes[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
|
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
|
||||||
. chr(0x40). chr(0x01) // operation: cups vendor extension: get defaults
|
. chr(0x40). chr(0x01) // operation: cups vendor extension: get defaults
|
||||||
@ -105,45 +111,55 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
$post_values = array( "Content-Type" => "application/ipp",
|
$post_values = array( "Content-Type" => "application/ipp",
|
||||||
"Data" => $this->output);
|
"Data" => $this->output);
|
||||||
|
|
||||||
if (self::_sendHttp ($post_values,'/')) {
|
if (self::_sendHttp ($post_values,'/'))
|
||||||
|
{
|
||||||
|
|
||||||
if(self::_parseServerOutput())
|
if(self::_parseServerOutput())
|
||||||
|
{
|
||||||
self::_parsePrinterAttributes();
|
self::_parsePrinterAttributes();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->attributes = &$this->printer_attributes;
|
$this->attributes = &$this->printer_attributes;
|
||||||
|
|
||||||
if (isset($this->printer_attributes->printer_type)) {
|
if (isset($this->printer_attributes->printer_type))
|
||||||
|
{
|
||||||
$printer_type = $this->printer_attributes->printer_type->_value0;
|
$printer_type = $this->printer_attributes->printer_type->_value0;
|
||||||
$table = self::_interpretPrinterType($printer_type);
|
$table = self::_interpretPrinterType($printer_type);
|
||||||
|
|
||||||
for($i = 0 ; $i < count($table) ; $i++ ) {
|
for($i = 0 ; $i < count($table) ; $i++ )
|
||||||
|
{
|
||||||
$index = '_value'.$i;
|
$index = '_value'.$i;
|
||||||
$this->printer_attributes->printer_type->$index = $table[$i];
|
$this->printer_attributes->printer_type->$index = $table[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->serveroutput) && isset($this->serveroutput->status)) {
|
if (isset($this->serveroutput) && isset($this->serveroutput->status))
|
||||||
|
{
|
||||||
|
|
||||||
$this->status = array_merge($this->status,array($this->serveroutput->status));
|
$this->status = array_merge($this->status,array($this->serveroutput->status));
|
||||||
if ($this->serveroutput->status == "successfull-ok")
|
if ($this->serveroutput->status == "successfull-ok")
|
||||||
|
{
|
||||||
self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
|
self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
|
self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->serveroutput->status;
|
return $this->serveroutput->status;
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
$this->status = array_merge($this->status,array("OPERATION FAILED"));
|
$this->status = array_merge($this->status,array("OPERATION FAILED"));
|
||||||
self::_errorLog("getting defaults : OPERATION FAILED",1);
|
self::_errorLog("getting defaults : OPERATION FAILED",1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
// {{{ cupsAcceptJobs ($printer_uri)
|
|
||||||
public function cupsAcceptJobs($printer_uri) {
|
public function cupsAcceptJobs($printer_uri)
|
||||||
|
{
|
||||||
//The CUPS-Get-Default operation returns the default printer URI and attributes
|
//The CUPS-Get-Default operation returns the default printer URI and attributes
|
||||||
|
|
||||||
$this->jobs = array_merge($this->jobs,array(""));
|
$this->jobs = array_merge($this->jobs,array(""));
|
||||||
@ -152,10 +168,14 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
unset($this->printer_attributes);
|
unset($this->printer_attributes);
|
||||||
|
|
||||||
if (!isset($this->setup->charset))
|
if (!isset($this->setup->charset))
|
||||||
self::setCharset('us-ascii');
|
{
|
||||||
|
self::setCharset();
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($this->setup->language))
|
if (!isset($this->setup->language))
|
||||||
|
{
|
||||||
self::setLanguage('en');
|
self::setLanguage('en');
|
||||||
|
}
|
||||||
|
|
||||||
self::_setOperationId();
|
self::_setOperationId();
|
||||||
|
|
||||||
@ -179,32 +199,41 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
$post_values = array( "Content-Type" => "application/ipp",
|
$post_values = array( "Content-Type" => "application/ipp",
|
||||||
"Data" => $this->output);
|
"Data" => $this->output);
|
||||||
|
|
||||||
if (self::_sendHttp ($post_values,'/admin/')) {
|
if (self::_sendHttp ($post_values,'/admin/'))
|
||||||
|
{
|
||||||
|
|
||||||
if(self::_parseServerOutput())
|
if(self::_parseServerOutput())
|
||||||
|
{
|
||||||
self::_parseAttributes();
|
self::_parseAttributes();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->serveroutput) && isset($this->serveroutput->status)) {
|
if (isset($this->serveroutput) && isset($this->serveroutput->status))
|
||||||
|
{
|
||||||
|
|
||||||
$this->status = array_merge($this->status,array($this->serveroutput->status));
|
$this->status = array_merge($this->status,array($this->serveroutput->status));
|
||||||
if ($this->serveroutput->status == "successfull-ok")
|
if ($this->serveroutput->status == "successfull-ok")
|
||||||
|
{
|
||||||
self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
|
self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
|
self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->serveroutput->status;
|
return $this->serveroutput->status;
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
$this->status = array_merge($this->status,array("OPERATION FAILED"));
|
$this->status = array_merge($this->status,array("OPERATION FAILED"));
|
||||||
self::_errorLog("getting defaults : OPERATION FAILED",1);
|
self::_errorLog("getting defaults : OPERATION FAILED",1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
// {{{ cupsRejectJobs ($printer_uri,$printer_state_message=false)
|
|
||||||
public function cupsRejectJobs($printer_uri,$printer_state_message) {
|
public function cupsRejectJobs($printer_uri,$printer_state_message)
|
||||||
|
{
|
||||||
//The CUPS-Get-Default operation returns the default printer URI and attributes
|
//The CUPS-Get-Default operation returns the default printer URI and attributes
|
||||||
|
|
||||||
$this->jobs = array_merge($this->jobs,array(""));
|
$this->jobs = array_merge($this->jobs,array(""));
|
||||||
@ -213,21 +242,27 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
unset($this->attributes);
|
unset($this->attributes);
|
||||||
|
|
||||||
if (!isset($this->setup->charset))
|
if (!isset($this->setup->charset))
|
||||||
self::setCharset('us-ascii');
|
{
|
||||||
|
self::setCharset();
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($this->setup->language))
|
if (!isset($this->setup->language))
|
||||||
|
{
|
||||||
self::setLanguage('en');
|
self::setLanguage('en');
|
||||||
|
}
|
||||||
|
|
||||||
self::_setOperationId();
|
self::_setOperationId();
|
||||||
|
|
||||||
$message = "";
|
$message = "";
|
||||||
if ($printer_state_message)
|
if ($printer_state_message)
|
||||||
|
{
|
||||||
$message = chr(0x04) // start printer-attributes
|
$message = chr(0x04) // start printer-attributes
|
||||||
. chr(0x41) // textWithoutLanguage
|
. chr(0x41) // textWithoutLanguage
|
||||||
. self::_giveMeStringLength("printer-state-message")
|
. self::_giveMeStringLength("printer-state-message")
|
||||||
. "printer-state-message"
|
. "printer-state-message"
|
||||||
. self::_giveMeStringLength($printer_state_message)
|
. self::_giveMeStringLength($printer_state_message)
|
||||||
. $printer_state_message;
|
. $printer_state_message;
|
||||||
|
}
|
||||||
|
|
||||||
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
|
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
|
||||||
. chr(0x40). chr(0x09) // operation: cups vendor extension: Reject-Jobs
|
. chr(0x40). chr(0x09) // operation: cups vendor extension: Reject-Jobs
|
||||||
@ -250,79 +285,101 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
$post_values = array( "Content-Type" => "application/ipp",
|
$post_values = array( "Content-Type" => "application/ipp",
|
||||||
"Data" => $this->output);
|
"Data" => $this->output);
|
||||||
|
|
||||||
if (self::_sendHttp ($post_values,'/admin/')) {
|
if (self::_sendHttp ($post_values,'/admin/'))
|
||||||
|
{
|
||||||
|
|
||||||
if(self::_parseServerOutput())
|
if(self::_parseServerOutput())
|
||||||
|
{
|
||||||
self::_parseAttributes();
|
self::_parseAttributes();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->serveroutput) && isset($this->serveroutput->status)) {
|
if (isset($this->serveroutput) && isset($this->serveroutput->status))
|
||||||
|
{
|
||||||
|
|
||||||
$this->status = array_merge($this->status,array($this->serveroutput->status));
|
$this->status = array_merge($this->status,array($this->serveroutput->status));
|
||||||
if ($this->serveroutput->status == "successfull-ok")
|
if ($this->serveroutput->status == "successfull-ok")
|
||||||
|
{
|
||||||
self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
|
self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
|
self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->serveroutput->status;
|
return $this->serveroutput->status;
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
$this->status = array_merge($this->status,array("OPERATION FAILED"));
|
$this->status = array_merge($this->status,array("OPERATION FAILED"));
|
||||||
self::_errorLog("getting defaults : OPERATION FAILED",1);
|
self::_errorLog("getting defaults : OPERATION FAILED",1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
// {{{ getPrinters()
|
|
||||||
public function getPrinters($printer_location=false,$printer_info=false,$attributes=array()) {
|
|
||||||
|
|
||||||
|
public function getPrinters($printer_location=false,$printer_info=false,$attributes=array())
|
||||||
|
{
|
||||||
if (count($attributes) == 0)
|
if (count($attributes) == 0)
|
||||||
|
{
|
||||||
true;
|
true;
|
||||||
$attributes=array('printer-uri-supported','printer-location','printer-info','printer-type','color-supported');
|
}
|
||||||
|
$attributes=array('printer-uri-supported', 'printer-location', 'printer-info', 'printer-type', 'color-supported', 'printer-name');
|
||||||
$this->jobs = array_merge($this->jobs,array(""));
|
$this->jobs = array_merge($this->jobs,array(""));
|
||||||
$this->jobs_uri = array_merge($this->jobs_uri,array(""));
|
$this->jobs_uri = array_merge($this->jobs_uri,array(""));
|
||||||
|
|
||||||
unset ($this->printers_attributes);
|
unset ($this->printers_attributes);
|
||||||
|
|
||||||
if (!isset($this->setup->charset))
|
if (!isset($this->setup->charset))
|
||||||
self::setCharset('us-ascii');
|
{
|
||||||
|
self::setCharset();
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($this->setup->language))
|
if (!isset($this->setup->language))
|
||||||
|
{
|
||||||
self::setLanguage('en-us');
|
self::setLanguage('en-us');
|
||||||
|
}
|
||||||
|
|
||||||
self::_setOperationId();
|
self::_setOperationId();
|
||||||
|
|
||||||
$this->meta->attributes='';
|
$this->meta->attributes='';
|
||||||
|
|
||||||
if ($printer_location)
|
if ($printer_location)
|
||||||
|
{
|
||||||
$this->meta->attributes .= chr(0x41) // textWithoutLanguage
|
$this->meta->attributes .= chr(0x41) // textWithoutLanguage
|
||||||
. self::_giveMeStringLength('printer-location')
|
. self::_giveMeStringLength('printer-location')
|
||||||
. 'printer-location'
|
. 'printer-location'
|
||||||
. self::_giveMeStringLength($printer_location)
|
. self::_giveMeStringLength($printer_location)
|
||||||
. $printer_location;
|
. $printer_location;
|
||||||
|
}
|
||||||
|
|
||||||
if ($printer_info)
|
if ($printer_info)
|
||||||
|
{
|
||||||
$this->meta->attributes .= chr(0x41) // textWithoutLanguage
|
$this->meta->attributes .= chr(0x41) // textWithoutLanguage
|
||||||
. self::_giveMeStringLength('printer-info')
|
. self::_giveMeStringLength('printer-info')
|
||||||
. 'printer-info'
|
. 'printer-info'
|
||||||
. self::_giveMeStringLength($printer_info)
|
. self::_giveMeStringLength($printer_info)
|
||||||
. $printer_info;
|
. $printer_info;
|
||||||
|
}
|
||||||
|
|
||||||
for($i = 0 ; $i < count($attributes) ; $i++)
|
for($i = 0 ; $i < count($attributes) ; $i++)
|
||||||
|
{
|
||||||
if ($i == 0)
|
if ($i == 0)
|
||||||
|
{
|
||||||
$this->meta->attributes .= chr(0x44) // Keyword
|
$this->meta->attributes .= chr(0x44) // Keyword
|
||||||
. self::_giveMeStringLength('requested-attributes')
|
. self::_giveMeStringLength('requested-attributes')
|
||||||
. 'requested-attributes'
|
. 'requested-attributes'
|
||||||
. self::_giveMeStringLength($attributes[0])
|
. self::_giveMeStringLength($attributes[0])
|
||||||
. $attributes[0];
|
. $attributes[0];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$this->meta->attributes .= chr(0x44) // Keyword
|
$this->meta->attributes .= chr(0x44) // Keyword
|
||||||
. chr(0x0).chr(0x0) // zero-length name
|
. chr(0x0).chr(0x0) // zero-length name
|
||||||
. self::_giveMeStringLength($attributes[$i])
|
. self::_giveMeStringLength($attributes[$i])
|
||||||
. $attributes[$i];
|
. $attributes[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
|
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
|
||||||
. chr(0x40). chr(0x02) // operation: cups vendor extension: get printers
|
. chr(0x40). chr(0x02) // operation: cups vendor extension: get printers
|
||||||
@ -338,51 +395,65 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
$post_values = array( "Content-Type" => "application/ipp",
|
$post_values = array( "Content-Type" => "application/ipp",
|
||||||
"Data" => $this->output);
|
"Data" => $this->output);
|
||||||
|
|
||||||
if (self::_sendHttp ($post_values,'/')) {
|
if (self::_sendHttp ($post_values,'/'))
|
||||||
|
{
|
||||||
|
|
||||||
if(self::_parseServerOutput())
|
if(self::_parseServerOutput())
|
||||||
|
{
|
||||||
$this->_getAvailablePrinters();
|
$this->_getAvailablePrinters();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->serveroutput) && isset($this->serveroutput->status)) {
|
if (isset($this->serveroutput) && isset($this->serveroutput->status))
|
||||||
|
{
|
||||||
|
|
||||||
$this->status = array_merge($this->status,array($this->serveroutput->status));
|
$this->status = array_merge($this->status,array($this->serveroutput->status));
|
||||||
if ($this->serveroutput->status == "successfull-ok")
|
if ($this->serveroutput->status == "successfull-ok")
|
||||||
|
{
|
||||||
self::_errorLog("getting printers: ".$this->serveroutput->status,3);
|
self::_errorLog("getting printers: ".$this->serveroutput->status,3);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
self::_errorLog("getting printers: ".$this->serveroutput->status,1);
|
self::_errorLog("getting printers: ".$this->serveroutput->status,1);
|
||||||
|
}
|
||||||
return $this->serveroutput->status;
|
return $this->serveroutput->status;
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
$this->status = array_merge($this->status,array("OPERATION FAILED"));
|
$this->status = array_merge($this->status,array("OPERATION FAILED"));
|
||||||
self::_errorLog("getting printers : OPERATION FAILED",1);
|
self::_errorLog("getting printers : OPERATION FAILED",1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
// {{{ cupsGetPrinters ()
|
|
||||||
public function cupsGetPrinters () {
|
public function cupsGetPrinters ()
|
||||||
|
{
|
||||||
// alias for getPrinters();
|
// alias for getPrinters();
|
||||||
self::getPrinters();
|
self::getPrinters();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
// {{{ getPrinterAttributes()
|
|
||||||
public function getPrinterAttributes() {
|
public function getPrinterAttributes()
|
||||||
|
{
|
||||||
// complete informations from parent with Cups-specific stuff
|
// complete informations from parent with Cups-specific stuff
|
||||||
|
|
||||||
if(!$result = parent::getPrinterAttributes())
|
if(!$result = parent::getPrinterAttributes())
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
if(!isset($this->printer_attributes))
|
if(!isset($this->printer_attributes))
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset ($this->printer_attributes->printer_type)) {
|
if (isset ($this->printer_attributes->printer_type))
|
||||||
|
{
|
||||||
$printer_type = $this->printer_attributes->printer_type->_value0;
|
$printer_type = $this->printer_attributes->printer_type->_value0;
|
||||||
$table = self::_interpretPrinterType($printer_type);
|
$table = self::_interpretPrinterType($printer_type);
|
||||||
|
|
||||||
for($i = 0 ; $i < count($table) ; $i++ ) {
|
for($i = 0 ; $i < count($table) ; $i++ )
|
||||||
|
{
|
||||||
$index = '_value'.$i;
|
$index = '_value'.$i;
|
||||||
$this->printer_attributes->printer_type->$index = $table[$i];
|
$this->printer_attributes->printer_type->$index = $table[$i];
|
||||||
}
|
}
|
||||||
@ -390,15 +461,12 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// SETUP
|
// SETUP
|
||||||
//
|
//
|
||||||
|
protected function _initTags ()
|
||||||
// {{{ _initTags ()
|
{
|
||||||
protected function _initTags () {
|
|
||||||
|
|
||||||
// override parent with specific cups attributes
|
// override parent with specific cups attributes
|
||||||
|
|
||||||
$operation_tags = array ();
|
$operation_tags = array ();
|
||||||
@ -434,21 +502,19 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
);
|
);
|
||||||
$this->job_tags = array_merge ($this->job_tags, $job_tags);
|
$this->job_tags = array_merge ($this->job_tags, $job_tags);
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// REQUEST BUILDING
|
// REQUEST BUILDING
|
||||||
//
|
//
|
||||||
|
protected function _enumBuild ($tag,$value)
|
||||||
// {{{ _enumBuild ($tag,$value)
|
{
|
||||||
protected function _enumBuild ($tag,$value) {
|
|
||||||
|
|
||||||
$value_built = parent::_enumBuild($tag,$value);
|
$value_built = parent::_enumBuild($tag,$value);
|
||||||
|
|
||||||
|
switch ($tag)
|
||||||
switch ($tag) {
|
{
|
||||||
case "cpi":
|
case "cpi":
|
||||||
switch ($value) {
|
switch ($value)
|
||||||
|
{
|
||||||
case '10':
|
case '10':
|
||||||
$value_built = chr(10);
|
$value_built = chr(10);
|
||||||
break;
|
break;
|
||||||
@ -463,7 +529,8 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "lpi":
|
case "lpi":
|
||||||
switch ($value) {
|
switch ($value)
|
||||||
|
{
|
||||||
case '6':
|
case '6':
|
||||||
$value_built = chr(6);
|
$value_built = chr(6);
|
||||||
break;
|
break;
|
||||||
@ -481,37 +548,40 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
$prepend .= chr(0);
|
$prepend .= chr(0);
|
||||||
return $prepend.$value_built;
|
return $prepend.$value_built;
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// RESPONSE PARSING
|
// RESPONSE PARSING
|
||||||
//
|
//
|
||||||
|
private function _getAvailablePrinters ()
|
||||||
// {{{ _getAvailablePrinters ()
|
{
|
||||||
private function _getAvailablePrinters () {
|
|
||||||
|
|
||||||
$this->available_printers = array();
|
$this->available_printers = array();
|
||||||
|
$this->printer_map = array();
|
||||||
$k = 0;
|
$k = 0;
|
||||||
$this->printers_attributes = new stdClass();
|
$this->printers_attributes = new \stdClass();
|
||||||
|
|
||||||
for ($i = 0 ; (array_key_exists($i,$this->serveroutput->response)) ; $i ++)
|
for ($i = 0 ; (array_key_exists($i,$this->serveroutput->response)) ; $i ++)
|
||||||
if (($this->serveroutput->response[$i]['attributes']) == "printer-attributes") {
|
{
|
||||||
|
if (($this->serveroutput->response[$i]['attributes']) == "printer-attributes")
|
||||||
|
{
|
||||||
$phpname = "_printer".$k;
|
$phpname = "_printer".$k;
|
||||||
$this->printers_attributes->$phpname = new stdClass();
|
$this->printers_attributes->$phpname = new \stdClass();
|
||||||
for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++) {
|
for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++)
|
||||||
|
{
|
||||||
|
|
||||||
$value = $this->serveroutput->response[$i][$j]['value'];
|
$value = $this->serveroutput->response[$i][$j]['value'];
|
||||||
$name = str_replace("-","_",$this->serveroutput->response[$i][$j]['name']);
|
$name = str_replace("-","_",$this->serveroutput->response[$i][$j]['name']);
|
||||||
|
|
||||||
switch ($name) {
|
switch ($name)
|
||||||
|
{
|
||||||
case "printer_uri_supported":
|
case "printer_uri_supported":
|
||||||
$this->available_printers = array_merge($this->available_printers,array($value));
|
$this->available_printers = array_merge($this->available_printers,array($value));
|
||||||
break;
|
break;
|
||||||
case "printer_type":
|
case "printer_type":
|
||||||
$table = self::_interpretPrinterType($value);
|
$table = self::_interpretPrinterType($value);
|
||||||
$this->printers_attributes->$phpname->$name = new stdClass();
|
$this->printers_attributes->$phpname->$name = new \stdClass();
|
||||||
|
|
||||||
for($l = 0 ; $l < count($table) ; $l++ ) {
|
for($l = 0 ; $l < count($table) ; $l++ )
|
||||||
|
{
|
||||||
$index = '_value'.$l;
|
$index = '_value'.$l;
|
||||||
$this->printers_attributes->$phpname->$name->$index = $table[$l];
|
$this->printers_attributes->$phpname->$name->$index = $table[$l];
|
||||||
}
|
}
|
||||||
@ -519,20 +589,23 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
break;
|
break;
|
||||||
case '':
|
case '':
|
||||||
break;
|
break;
|
||||||
|
case 'printer_name':
|
||||||
|
$this->printer_map[$value] = $k;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$this->printers_attributes->$phpname->$name = $value;
|
$this->printers_attributes->$phpname->$name = $value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$k ++;
|
$k ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }}}
|
}
|
||||||
|
|
||||||
// {{{ _getEnumVendorExtensions
|
protected function _getEnumVendorExtensions ($value_parsed)
|
||||||
protected function _getEnumVendorExtensions ($value_parsed) {
|
{
|
||||||
switch ($value_parsed) {
|
switch ($value_parsed)
|
||||||
|
{
|
||||||
case 0x4002:
|
case 0x4002:
|
||||||
$value = 'Get-Availables-Printers';
|
$value = 'Get-Availables-Printers';
|
||||||
break;
|
break;
|
||||||
@ -542,109 +615,151 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($value))
|
if (isset($value))
|
||||||
|
{
|
||||||
return ($value);
|
return ($value);
|
||||||
|
}
|
||||||
|
|
||||||
return sprintf('Unknown: 0x%x',$value_parsed);
|
return sprintf('Unknown: 0x%x',$value_parsed);
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
// {{{ _interpretPrinterType($type)
|
|
||||||
private function _interpretPrinterType($value) {
|
private function _interpretPrinterType($value)
|
||||||
|
{
|
||||||
$value_parsed = 0;
|
$value_parsed = 0;
|
||||||
for ($i = strlen($value) ; $i > 0 ; $i --)
|
for ($i = strlen($value) ; $i > 0 ; $i --)
|
||||||
|
{
|
||||||
$value_parsed += pow(256,($i - 1)) * ord($value[strlen($value) - $i]);
|
$value_parsed += pow(256,($i - 1)) * ord($value[strlen($value) - $i]);
|
||||||
|
}
|
||||||
|
|
||||||
$type[0] = $type[1] = $type[2] = $type[3] = $type[4] = $type[5] = '';
|
$type[0] = $type[1] = $type[2] = $type[3] = $type[4] = $type[5] = '';
|
||||||
$type[6] = $type[7] = $type[8] = $type[9] = $type[10] = '';
|
$type[6] = $type[7] = $type[8] = $type[9] = $type[10] = '';
|
||||||
$type[11] = $type[12] = $type[13] = $type[14] = $type[15] = '';
|
$type[11] = $type[12] = $type[13] = $type[14] = $type[15] = '';
|
||||||
$type[16] = $type[17] = $type[18] = $type[19] = '';
|
$type[16] = $type[17] = $type[18] = $type[19] = '';
|
||||||
|
|
||||||
if ($value_parsed %2 == 1) {
|
if ($value_parsed %2 == 1)
|
||||||
|
{
|
||||||
$type[0] = 'printer-class';
|
$type[0] = 'printer-class';
|
||||||
$value_parsed -= 1;
|
$value_parsed -= 1;
|
||||||
}
|
}
|
||||||
if ($value_parsed %4 == 2 ) {
|
|
||||||
|
if ($value_parsed %4 == 2 )
|
||||||
|
{
|
||||||
$type[1] = 'remote-destination';
|
$type[1] = 'remote-destination';
|
||||||
$value_parsed -= 2;
|
$value_parsed -= 2;
|
||||||
}
|
}
|
||||||
if ($value_parsed %8 == 4 ) {
|
|
||||||
|
if ($value_parsed %8 == 4 )
|
||||||
|
{
|
||||||
$type[2] = 'print-black';
|
$type[2] = 'print-black';
|
||||||
$value_parsed -= 4;
|
$value_parsed -= 4;
|
||||||
}
|
}
|
||||||
if ($value_parsed %16 == 8 ) {
|
|
||||||
|
if ($value_parsed %16 == 8 )
|
||||||
|
{
|
||||||
$type[3] = 'print-color';
|
$type[3] = 'print-color';
|
||||||
$value_parsed -= 8;
|
$value_parsed -= 8;
|
||||||
}
|
}
|
||||||
if ($value_parsed %32 == 16) {
|
|
||||||
|
if ($value_parsed %32 == 16)
|
||||||
|
{
|
||||||
$type[4] = 'hardware-print-on-both-sides';
|
$type[4] = 'hardware-print-on-both-sides';
|
||||||
$value_parsed -= 16;
|
$value_parsed -= 16;
|
||||||
}
|
}
|
||||||
if ($value_parsed %64 == 32) {
|
|
||||||
|
if ($value_parsed %64 == 32)
|
||||||
|
{
|
||||||
$type[5] = 'hardware-staple-output';
|
$type[5] = 'hardware-staple-output';
|
||||||
$value_parsed -= 32;
|
$value_parsed -= 32;
|
||||||
}
|
}
|
||||||
if ($value_parsed %128 == 64) {
|
|
||||||
|
if ($value_parsed %128 == 64)
|
||||||
|
{
|
||||||
$type[6] = 'hardware-fast-copies';
|
$type[6] = 'hardware-fast-copies';
|
||||||
$value_parsed -= 64;
|
$value_parsed -= 64;
|
||||||
}
|
}
|
||||||
if ($value_parsed %256 == 128) {
|
|
||||||
|
if ($value_parsed %256 == 128)
|
||||||
|
{
|
||||||
$type[7] = 'hardware-fast-copy-collation';
|
$type[7] = 'hardware-fast-copy-collation';
|
||||||
$value_parsed -= 128;
|
$value_parsed -= 128;
|
||||||
}
|
}
|
||||||
if ($value_parsed %512 == 256) {
|
|
||||||
|
if ($value_parsed %512 == 256)
|
||||||
|
{
|
||||||
$type[8] = 'punch-output';
|
$type[8] = 'punch-output';
|
||||||
$value_parsed -= 256;
|
$value_parsed -= 256;
|
||||||
}
|
}
|
||||||
if ($value_parsed %1024 == 512) {
|
|
||||||
|
if ($value_parsed %1024 == 512)
|
||||||
|
{
|
||||||
$type[9] = 'cover-output';
|
$type[9] = 'cover-output';
|
||||||
$value_parsed -= 512;
|
$value_parsed -= 512;
|
||||||
}
|
}
|
||||||
if ($value_parsed %2048 == 1024) {
|
|
||||||
|
if ($value_parsed %2048 == 1024)
|
||||||
|
{
|
||||||
$type[10] = 'bind-output';
|
$type[10] = 'bind-output';
|
||||||
$value_parsed -= 1024;
|
$value_parsed -= 1024;
|
||||||
}
|
}
|
||||||
if ($value_parsed %4096 == 2048) {
|
|
||||||
|
if ($value_parsed %4096 == 2048)
|
||||||
|
{
|
||||||
$type[11] = 'sort-output';
|
$type[11] = 'sort-output';
|
||||||
$value_parsed -= 2048;
|
$value_parsed -= 2048;
|
||||||
}
|
}
|
||||||
if ($value_parsed %8192 == 4096) {
|
|
||||||
|
if ($value_parsed %8192 == 4096)
|
||||||
|
{
|
||||||
$type[12] = 'handle-media-up-to-US-Legal-A4';
|
$type[12] = 'handle-media-up-to-US-Legal-A4';
|
||||||
$value_parsed -= 4096;
|
$value_parsed -= 4096;
|
||||||
}
|
}
|
||||||
if ($value_parsed %16384 == 8192) {
|
|
||||||
|
if ($value_parsed %16384 == 8192)
|
||||||
|
{
|
||||||
$type[13] = 'handle-media-between-US-Legal-A4-and-ISO_C-A2';
|
$type[13] = 'handle-media-between-US-Legal-A4-and-ISO_C-A2';
|
||||||
$value_parsed -= 8192;
|
$value_parsed -= 8192;
|
||||||
}
|
}
|
||||||
if ($value_parsed %32768 == 16384) {
|
|
||||||
|
if ($value_parsed %32768 == 16384)
|
||||||
|
{
|
||||||
$type[14] = 'handle-media-larger-than-ISO_C-A2';
|
$type[14] = 'handle-media-larger-than-ISO_C-A2';
|
||||||
$value_parsed -= 16384;
|
$value_parsed -= 16384;
|
||||||
}
|
}
|
||||||
if ($value_parsed %65536 == 32768) {
|
|
||||||
|
if ($value_parsed %65536 == 32768)
|
||||||
|
{
|
||||||
$type[15] = 'handle-user-defined-media-sizes';
|
$type[15] = 'handle-user-defined-media-sizes';
|
||||||
$value_parsed -= 32768;
|
$value_parsed -= 32768;
|
||||||
}
|
}
|
||||||
if ($value_parsed %131072 == 65536) {
|
|
||||||
|
if ($value_parsed %131072 == 65536)
|
||||||
|
{
|
||||||
$type[16] = 'implicit-server-generated-class';
|
$type[16] = 'implicit-server-generated-class';
|
||||||
$value_parsed -= 65536;
|
$value_parsed -= 65536;
|
||||||
}
|
}
|
||||||
if ($value_parsed %262144 == 131072) {
|
|
||||||
|
if ($value_parsed %262144 == 131072)
|
||||||
|
{
|
||||||
$type[17] = 'network-default-printer';
|
$type[17] = 'network-default-printer';
|
||||||
$value_parsed -= 131072;
|
$value_parsed -= 131072;
|
||||||
}
|
}
|
||||||
if ($value_parsed %524288 == 262144) {
|
|
||||||
|
if ($value_parsed %524288 == 262144)
|
||||||
|
{
|
||||||
$type[18] = 'fax-device';
|
$type[18] = 'fax-device';
|
||||||
$value_parsed -= 262144;
|
$value_parsed -= 262144;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
// {{{ _interpretEnum()
|
|
||||||
protected function _interpretEnum($attribute_name,$value) {
|
|
||||||
|
|
||||||
|
protected function _interpretEnum($attribute_name,$value)
|
||||||
|
{
|
||||||
$value_parsed = self::_interpretInteger($value);
|
$value_parsed = self::_interpretInteger($value);
|
||||||
|
|
||||||
switch ($attribute_name) {
|
switch ($attribute_name)
|
||||||
|
{
|
||||||
case 'cpi':
|
case 'cpi':
|
||||||
case 'lpi':
|
case 'lpi':
|
||||||
$value = $value_parsed;
|
$value = $value_parsed;
|
||||||
@ -654,18 +769,6 @@ class CupsPrintIPP extends ExtendedPrintIPP {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
// }}}
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Local variables:
|
|
||||||
* mode: php
|
|
||||||
* tab-width: 4
|
|
||||||
* c-basic-offset: 4
|
|
||||||
* End:
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* This class is intended to implement a subset of Hyper Text Transfer Protocol
|
* This class is intended to implement a subset of Hyper Text Transfer Protocol
|
||||||
* (HTTP/1.1) on client side (currently: POST operation), with file streaming
|
* (HTTP/1.1) on client side (currently: POST operation), with file streaming
|
||||||
* capability.
|
* capability.
|
||||||
*
|
*
|
||||||
* It can perform Basic and Digest authentication.
|
* It can perform Basic and Digest authentication.
|
||||||
@ -67,16 +67,19 @@
|
|||||||
class httpException extends Exception
|
class httpException extends Exception
|
||||||
{
|
{
|
||||||
protected $errno;
|
protected $errno;
|
||||||
|
|
||||||
public function __construct ($msg, $errno = null)
|
public function __construct ($msg, $errno = null)
|
||||||
{
|
{
|
||||||
parent::__construct ($msg);
|
parent::__construct ($msg);
|
||||||
$this->errno = $errno;
|
$this->errno = $errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getErrorFormatted ()
|
public function getErrorFormatted ()
|
||||||
{
|
{
|
||||||
return sprintf ("[http_class]: %s -- "._(" file %s, line %s"),
|
return sprintf ("[http_class]: %s -- "._(" file %s, line %s"),
|
||||||
$this->getMessage (), $this->getFile (), $this->getLine ());
|
$this->getMessage (), $this->getFile (), $this->getLine ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getErrno ()
|
public function getErrno ()
|
||||||
{
|
{
|
||||||
return $this->errno;
|
return $this->errno;
|
||||||
@ -98,7 +101,9 @@ function error2string($value)
|
|||||||
E_USER_WARNING => 'E_USER_WARNING',
|
E_USER_WARNING => 'E_USER_WARNING',
|
||||||
E_USER_NOTICE => 'E_USER_NOTICE'
|
E_USER_NOTICE => 'E_USER_NOTICE'
|
||||||
);
|
);
|
||||||
if(defined('E_STRICT')) $level_names[E_STRICT]='E_STRICT';
|
if(defined('E_STRICT')) {
|
||||||
|
$level_names[E_STRICT]='E_STRICT';
|
||||||
|
}
|
||||||
$levels=array();
|
$levels=array();
|
||||||
if(($value&E_ALL)==E_ALL)
|
if(($value&E_ALL)==E_ALL)
|
||||||
{
|
{
|
||||||
@ -106,7 +111,12 @@ function error2string($value)
|
|||||||
$value&=~E_ALL;
|
$value&=~E_ALL;
|
||||||
}
|
}
|
||||||
foreach($level_names as $level=>$name)
|
foreach($level_names as $level=>$name)
|
||||||
if(($value&$level)==$level) $levels[]=$name;
|
{
|
||||||
|
if(($value&$level)==$level)
|
||||||
|
{
|
||||||
|
$levels[]=$name;
|
||||||
|
}
|
||||||
|
}
|
||||||
return implode(' | ',$levels);
|
return implode(' | ',$levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,14 +170,13 @@ class http_class
|
|||||||
public function GetRequestArguments ($url, &$arguments)
|
public function GetRequestArguments ($url, &$arguments)
|
||||||
{
|
{
|
||||||
$this->arguments = array ();
|
$this->arguments = array ();
|
||||||
$arguments["URL"] = $this->arguments["URL"] = $url;
|
$this->arguments["URL"] = $arguments["URL"] = $url;
|
||||||
$arguments["RequestMethod"] = $this->arguments["RequestMethod"] = "POST";
|
$this->arguments["RequestMethod"] = $arguments["RequestMethod"] = "POST";
|
||||||
$this->headers["Content-Length"] = 0;
|
$this->headers["Content-Length"] = 0;
|
||||||
$this->headers["Content-Type"] = "application/octet-stream";
|
$this->headers["Content-Type"] = "application/octet-stream";
|
||||||
$this->headers["Host"] = $this->host;
|
$this->headers["Host"] = $this->host;
|
||||||
$this->headers["User-Agent"] = $this->user_agent;
|
$this->headers["User-Agent"] = $this->user_agent;
|
||||||
//$this->headers["Expect"] = "100-continue";
|
//$this->headers["Expect"] = "100-continue";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Open ($arguments)
|
public function Open ($arguments)
|
||||||
@ -214,9 +223,13 @@ class http_class
|
|||||||
return $this->_HttpError ($error, E_USER_WARNING);
|
return $this->_HttpError ($error, E_USER_WARNING);
|
||||||
}
|
}
|
||||||
if (strstr ($url, ":")) // we got an ipv6 address
|
if (strstr ($url, ":")) // we got an ipv6 address
|
||||||
|
{
|
||||||
if (!strstr ($url, "[")) // it is not escaped
|
if (!strstr ($url, "[")) // it is not escaped
|
||||||
|
{
|
||||||
$url = sprintf ("[%s]", $url);
|
$url = sprintf ("[%s]", $url);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->connection = @fsockopen ($transport_type.$url, $port, $errno, $errstr, $this->timeout);
|
$this->connection = @fsockopen ($transport_type.$url, $port, $errno, $errstr, $this->timeout);
|
||||||
$error =
|
$error =
|
||||||
sprintf (_('Unable to connect to "%s%s port %s": %s'), $transport_type,
|
sprintf (_('Unable to connect to "%s%s port %s": %s'), $transport_type,
|
||||||
@ -269,14 +282,11 @@ class http_class
|
|||||||
$authtype[0]);
|
$authtype[0]);
|
||||||
return $this->_HttpError ($error, E_USER_WARNING);
|
return $this->_HttpError ($error, E_USER_WARNING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
self::Close ();
|
self::Close ();
|
||||||
self::Open ($arguments);
|
self::Open ($arguments);
|
||||||
$error =
|
|
||||||
sprintf (_
|
$error = sprintf(_('Streaming request failed to %s after a try to authenticate'), $arguments['RequestURI']);
|
||||||
('Streaming request failed to %s after a try to authenticate'),
|
|
||||||
$url);
|
|
||||||
$result = self::_StreamRequest ($arguments);
|
$result = self::_StreamRequest ($arguments);
|
||||||
if (!$result[0])
|
if (!$result[0])
|
||||||
{
|
{
|
||||||
@ -300,7 +310,9 @@ class http_class
|
|||||||
public function Close ()
|
public function Close ()
|
||||||
{
|
{
|
||||||
if (!$this->connected)
|
if (!$this->connected)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
fclose ($this->connection);
|
fclose ($this->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +325,7 @@ class http_class
|
|||||||
private function _HttpError ($msg, $level, $errno = null)
|
private function _HttpError ($msg, $level, $errno = null)
|
||||||
{
|
{
|
||||||
$trace = '';
|
$trace = '';
|
||||||
$backtrace = debug_backtrace;
|
$backtrace = debug_backtrace();
|
||||||
foreach ($backtrace as $trace)
|
foreach ($backtrace as $trace)
|
||||||
{
|
{
|
||||||
$trace .= sprintf ("in [file: '%s'][function: '%s'][line: %s];\n", $trace['file'], $trace['function'],$trace['line']);
|
$trace .= sprintf ("in [file: '%s'][function: '%s'][line: %s];\n", $trace['file'], $trace['function'],$trace['line']);
|
||||||
@ -348,7 +360,7 @@ class http_class
|
|||||||
$this->reply_body = "";
|
$this->reply_body = "";
|
||||||
if (!$this->connected)
|
if (!$this->connected)
|
||||||
{
|
{
|
||||||
return _HttpError (_("not connected"), E_USER_WARNING);
|
return $this->_HttpError (_("not connected"), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
$this->arguments = $arguments;
|
$this->arguments = $arguments;
|
||||||
$content_length = 0;
|
$content_length = 0;
|
||||||
@ -369,39 +381,28 @@ class http_class
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$length = 0;
|
$length = 0;
|
||||||
return
|
return $this->_HttpError (sprintf (_("%s: file is not readable"), $value), E_USER_WARNING);
|
||||||
_HttpError (sprintf (_("%s: file is not readable"), $value),
|
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$length = 0;
|
$length = 0;
|
||||||
return
|
return $this->_HttpError (sprintf(_("%s: not a valid argument for content"), $type), E_USER_WARNING);
|
||||||
_HttpError (sprintf
|
|
||||||
(_("%s: not a valid argument for content"), $type),
|
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
$content_length += $length;
|
$content_length += $length;
|
||||||
}
|
}
|
||||||
$this->request_body = sprintf (_("%s Bytes"), $content_length);
|
$this->request_body = sprintf (_("%s Bytes"), $content_length);
|
||||||
$this->headers["Content-Length"] = $content_length;
|
$this->headers["Content-Length"] = $content_length;
|
||||||
$this->arguments["Headers"] =
|
$this->arguments["Headers"] = array_merge ($this->headers, $this->arguments["Headers"]);
|
||||||
array_merge ($this->headers, $this->arguments["Headers"]);
|
|
||||||
if ($this->arguments["RequestMethod"] != "POST")
|
if ($this->arguments["RequestMethod"] != "POST")
|
||||||
{
|
{
|
||||||
return
|
return $this->_HttpError (sprintf(_("%s: method not implemented"), $arguments["RequestMethod"]), E_USER_WARNING);
|
||||||
_HttpError (sprintf
|
|
||||||
(_("%s: method not implemented"),
|
|
||||||
$arguments["RequestMethod"]), E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
$string =
|
$string = sprintf ("POST %s HTTP/1.1\r\n", $this->arguments["RequestURI"]);
|
||||||
sprintf ("POST %s HTTP/1.1\r\n", $this->arguments["RequestURI"]);
|
|
||||||
$this->request_headers[$string] = '';
|
$this->request_headers[$string] = '';
|
||||||
if (!$this->_streamString ($string))
|
if (!$this->_streamString ($string))
|
||||||
{
|
{
|
||||||
return _HttpError (_("Error while puts POST operation"),
|
return $this->_HttpError (_("Error while puts POST operation"), E_USER_WARNING);
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
foreach ($this->arguments["Headers"] as $header => $value)
|
foreach ($this->arguments["Headers"] as $header => $value)
|
||||||
{
|
{
|
||||||
@ -409,15 +410,13 @@ class http_class
|
|||||||
$this->request_headers[$header] = $value;
|
$this->request_headers[$header] = $value;
|
||||||
if (!$this->_streamString ($string))
|
if (!$this->_streamString ($string))
|
||||||
{
|
{
|
||||||
return _HttpError (_("Error while puts HTTP headers"),
|
return $this->_HttpError (_("Error while puts HTTP headers"), E_USER_WARNING);
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$string = "\r\n";
|
$string = "\r\n";
|
||||||
if (!$this->_streamString ($string))
|
if (!$this->_streamString ($string))
|
||||||
{
|
{
|
||||||
return _HttpError (_("Error while ends HTTP headers"),
|
return $this->_HttpError (_("Error while ends HTTP headers"), E_USER_WARNING);
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
foreach ($this->arguments["BodyStream"] as $argument)
|
foreach ($this->arguments["BodyStream"] as $argument)
|
||||||
{
|
{
|
||||||
@ -431,8 +430,7 @@ class http_class
|
|||||||
$string = substr ($value, $streamed_length, $this->window_size);
|
$string = substr ($value, $streamed_length, $this->window_size);
|
||||||
if (!$this->_streamString ($string))
|
if (!$this->_streamString ($string))
|
||||||
{
|
{
|
||||||
return _HttpError (_("error while sending body data"),
|
return $this->_HttpError (_("error while sending body data"), E_USER_WARNING);
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
$streamed_length += $this->window_size;
|
$streamed_length += $this->window_size;
|
||||||
}
|
}
|
||||||
@ -444,16 +442,13 @@ class http_class
|
|||||||
$file = fopen ($value, 'rb');
|
$file = fopen ($value, 'rb');
|
||||||
while (!feof ($file))
|
while (!feof ($file))
|
||||||
{
|
{
|
||||||
if (gettype ($block = @fread ($file, $this->window_size)) !=
|
if (gettype ($block = @fread ($file, $this->window_size)) != "string")
|
||||||
"string")
|
|
||||||
{
|
{
|
||||||
return _HttpError (_("cannot read file to upload"),
|
return $this->_HttpError (_("cannot read file to upload"), E_USER_WARNING);
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
if (!$this->_streamString ($block))
|
if (!$this->_streamString ($block))
|
||||||
{
|
{
|
||||||
return _HttpError (_("error while sending body data"),
|
return $this->_HttpError (_("error while sending body data"), E_USER_WARNING);
|
||||||
E_USER_WARNING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,7 +471,9 @@ class http_class
|
|||||||
{
|
{
|
||||||
$line = fgets ($this->connection, 1024);
|
$line = fgets ($this->connection, 1024);
|
||||||
if (strlen (trim($line)) == 0)
|
if (strlen (trim($line)) == 0)
|
||||||
break; // \r\n => end of headers
|
{
|
||||||
|
break;
|
||||||
|
} // \r\n => end of headers
|
||||||
if (preg_match ('#^[[:space:]]#', $line))
|
if (preg_match ('#^[[:space:]]#', $line))
|
||||||
{
|
{
|
||||||
$headers[-1] .= sprintf(' %s', trim ($line));
|
$headers[-1] .= sprintf(' %s', trim ($line));
|
||||||
@ -553,7 +550,7 @@ class http_class
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return _HttpError(
|
return $this->_HttpError(
|
||||||
sprintf (_("digest Authorization: algorithm '%s' not implemented"),
|
sprintf (_("digest Authorization: algorithm '%s' not implemented"),
|
||||||
$algorithm),
|
$algorithm),
|
||||||
E_USER_WARNING);
|
E_USER_WARNING);
|
||||||
@ -568,7 +565,9 @@ class http_class
|
|||||||
#$qop = split (" ", $qop);
|
#$qop = split (" ", $qop);
|
||||||
$qop = preg_split ("# #", $qop);
|
$qop = preg_split ("# #", $qop);
|
||||||
if (in_array ("auth", $qop))
|
if (in_array ("auth", $qop))
|
||||||
|
{
|
||||||
$qop = "auth";
|
$qop = "auth";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self::_HttpError(
|
self::_HttpError(
|
||||||
@ -591,25 +590,23 @@ class http_class
|
|||||||
$username, $fields["realm"], $fields['nonce'],
|
$username, $fields["realm"], $fields['nonce'],
|
||||||
$this->arguments["RequestURI"], $response);
|
$this->arguments["RequestURI"], $response);
|
||||||
if (isset ($algorithm))
|
if (isset ($algorithm))
|
||||||
|
{
|
||||||
$auth_scheme .= sprintf (', algorithm="%s"', $algorithm);
|
$auth_scheme .= sprintf (', algorithm="%s"', $algorithm);
|
||||||
|
}
|
||||||
if (isset ($qop))
|
if (isset ($qop))
|
||||||
|
{
|
||||||
$auth_scheme .= sprintf (', cnonce="%s"', $cnonce);
|
$auth_scheme .= sprintf (', cnonce="%s"', $cnonce);
|
||||||
|
}
|
||||||
if (array_key_exists ("opaque", $fields))
|
if (array_key_exists ("opaque", $fields))
|
||||||
|
{
|
||||||
$auth_scheme .= sprintf (', opaque="%s"', $fields['opaque']);
|
$auth_scheme .= sprintf (', opaque="%s"', $fields['opaque']);
|
||||||
|
}
|
||||||
if (isset ($qop))
|
if (isset ($qop))
|
||||||
|
{
|
||||||
$auth_scheme .= sprintf (', qop="%s"', $qop);
|
$auth_scheme .= sprintf (', qop="%s"', $qop);
|
||||||
|
}
|
||||||
$auth_scheme .= sprintf (', nc=%s', $nc);
|
$auth_scheme .= sprintf (', nc=%s', $nc);
|
||||||
$this->nc++;
|
$this->nc++;
|
||||||
return $auth_scheme;
|
return $auth_scheme;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Local variables:
|
|
||||||
* mode: php
|
|
||||||
* tab-width: 2
|
|
||||||
* c-basic-offset: 2
|
|
||||||
* End:
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
|
|||||||
@ -40,13 +40,13 @@ insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG
|
|||||||
insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_FILE','DOL_DATA_ROOT/dolibarr.log','chaine','Directory where to write log file',0,0);
|
insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_FILE','DOL_DATA_ROOT/dolibarr.log','chaine','Directory where to write log file',0,0);
|
||||||
insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_LEVEL','7','chaine','Level of debug info to show',0,0);
|
insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_LEVEL','7','chaine','Level of debug info to show',0,0);
|
||||||
|
|
||||||
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_SMTP_SERVER','','chaine','Host or ip address for SMTP server',0,0);
|
|
||||||
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_SMTP_PORT','','chaine','Port for SMTP server',0,0);
|
|
||||||
|
|
||||||
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_UPLOAD_DOC','2048','chaine','Max size for file upload (0 means no upload allowed)',0,0);
|
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_UPLOAD_DOC','2048','chaine','Max size for file upload (0 means no upload allowed)',0,0);
|
||||||
|
|
||||||
-- Hidden but specific to one entity
|
-- Hidden but specific to one entity
|
||||||
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MONNAIE','EUR','chaine','Monnaie',0,1);
|
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MONNAIE','EUR','chaine','Monnaie',0,1);
|
||||||
|
|
||||||
|
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_SMTP_SERVER','','chaine','Host or ip address for SMTP server',0,1);
|
||||||
|
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_SMTP_PORT','','chaine','Port for SMTP server',0,1);
|
||||||
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_EMAIL_FROM','robot@domain.com','chaine','EMail emetteur pour les emails automatiques Dolibarr',0,1);
|
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_EMAIL_FROM','robot@domain.com','chaine','EMail emetteur pour les emails automatiques Dolibarr',0,1);
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
@ -26,14 +26,47 @@ create table llx_c_price_expression
|
|||||||
expression varchar(80) NOT NULL
|
expression varchar(80) NOT NULL
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|
||||||
|
--create table for user conf of printing driver
|
||||||
|
CREATE TABLE llx_printing
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
datec datetime,
|
||||||
|
printer_name text NOT NULL,
|
||||||
|
printer_location text NOT NULL,
|
||||||
|
printer_id varchar(255) NOT NULL,
|
||||||
|
copy integer NOT NULL DEFAULT '1',
|
||||||
|
module varchar(16) NOT NULL,
|
||||||
|
driver varchar(16) NOT NULL,
|
||||||
|
userid integer
|
||||||
|
)ENGINE=innodb;
|
||||||
|
|
||||||
ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAULT NULL;
|
ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAULT NULL;
|
||||||
|
|
||||||
-- Taiwan VAT Rates
|
-- Taiwan VAT Rates
|
||||||
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 2131, 213, '5', '0', 'VAT 5%', 1);
|
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 2131, 213, '5', '0', 'VAT 5%', 1);
|
||||||
|
|
||||||
-- Add situation invoices
|
-- Add situation invoices
|
||||||
ALTER TABLE llx_facture ADD situation_cycle_ref integer;
|
ALTER TABLE llx_facture ADD COLUMN situation_cycle_ref smallint;
|
||||||
ALTER TABLE llx_facture ADD situation_counter integer;
|
ALTER TABLE llx_facture ADD COLUMN situation_counter smallint;
|
||||||
ALTER TABLE llx_facture ADD situation_final integer;
|
ALTER TABLE llx_facture ADD COLUMN situation_final smallint;
|
||||||
ALTER TABLE llx_facturedet ADD situation_percent real;
|
ALTER TABLE llx_facturedet ADD COLUMN situation_percent real;
|
||||||
ALTER TABLE llx_facturedet ADD fk_prev_id integer;
|
ALTER TABLE llx_facturedet ADD COLUMN fk_prev_id integer;
|
||||||
|
|
||||||
|
-- Convert SMTP config to main entity, so new entities don't get the old values
|
||||||
|
UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SENDMODE";
|
||||||
|
UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTP_PORT";
|
||||||
|
UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTP_SERVER";
|
||||||
|
UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTPS_ID";
|
||||||
|
UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTPS_PW";
|
||||||
|
UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_EMAIL_TLS";
|
||||||
|
|
||||||
|
|
||||||
|
create table llx_bank_account_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL,
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
) ENGINE=innodb;
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ create table llx_contrat
|
|||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
ref varchar(30), -- contrat reference
|
ref varchar(30), -- contrat reference
|
||||||
ref_supplier varchar(30), -- suplier contract ref
|
ref_supplier varchar(30), -- suplier contract ref
|
||||||
|
ref_ext varchar(30), -- external contract ref
|
||||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
tms timestamp,
|
tms timestamp,
|
||||||
datec datetime, -- creation date
|
datec datetime, -- creation date
|
||||||
|
|||||||
@ -78,8 +78,8 @@ create table llx_facture
|
|||||||
import_key varchar(14),
|
import_key varchar(14),
|
||||||
extraparams varchar(255), -- for stock other parameters with json format
|
extraparams varchar(255), -- for stock other parameters with json format
|
||||||
|
|
||||||
situation_cycle_ref smallint UNSIGNED, -- situation cycle reference
|
situation_cycle_ref smallint, -- situation cycle reference
|
||||||
situation_counter tinyint UNSIGNED, -- situation counter
|
situation_counter smallint, -- situation counter
|
||||||
situation_final boolean -- is the situation final ?
|
situation_final smallint -- is the situation final ?
|
||||||
|
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
-- Copyright (C) 2013 Florian HENRY <florian.henry@open-concept.pro>
|
-- Copyright (C) 2013 Florian HENRY <florian.henry@open-concept.pro>
|
||||||
|
-- Copyright (C) 2014 Frederic France <frederic.france@free.fr>
|
||||||
--
|
--
|
||||||
-- This program is free software; you can redistribute it and/or modify
|
-- 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
|
-- it under the terms of the GNU General Public License as published by
|
||||||
@ -16,15 +17,16 @@
|
|||||||
--
|
--
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
|
|
||||||
CREATE TABLE llx_printer_ipp
|
CREATE TABLE llx_printing
|
||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
tms timestamp,
|
tms timestamp,
|
||||||
datec datetime,
|
datec datetime,
|
||||||
printer_name text NOT NULL,
|
printer_name text NOT NULL,
|
||||||
printer_location text NOT NULL,
|
printer_location text NOT NULL,
|
||||||
printer_uri varchar(255) NOT NULL,
|
printer_id varchar(255) NOT NULL,
|
||||||
copy integer NOT NULL DEFAULT '1',
|
copy integer NOT NULL DEFAULT '1',
|
||||||
module varchar(16) NOT NULL,
|
module varchar(16) NOT NULL,
|
||||||
login varchar(32) NOT NULL
|
driver varchar(16) NOT NULL,
|
||||||
|
userid integer
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
@ -1040,7 +1040,7 @@ SendingMailSetup=Setup of sendings by email
|
|||||||
SendmailOptionNotComplete=Warning, on some Linux systems, to send email from your email, sendmail execution setup must contains option -ba (parameter mail.force_extra_parameters into your php.ini file). If some recipients never receive emails, try to edit this PHP parameter with mail.force_extra_parameters = -ba).
|
SendmailOptionNotComplete=Warning, on some Linux systems, to send email from your email, sendmail execution setup must contains option -ba (parameter mail.force_extra_parameters into your php.ini file). If some recipients never receive emails, try to edit this PHP parameter with mail.force_extra_parameters = -ba).
|
||||||
PathToDocuments=Path to documents
|
PathToDocuments=Path to documents
|
||||||
PathDirectory=Directory
|
PathDirectory=Directory
|
||||||
SendmailOptionMayHurtBuggedMTA=Feature to send mails using method "PHP mail direct" will generate a mail message that might be not correctly parsed by some receiving mail servers. Result is that some mails can't be read by people hosted by thoose bugged platforms. It's case for some Internet providers (Ex: Orange in France). This is not a problem into Dolibarr nor into PHP but onto receiving mail server. You can however add option MAIN_FIX_FOR_BUGGED_MTA to 1 into setup - other to modify Dolibarr to avoid this. However, you may experience problem with other servers that respect strictly the SMTP standard. The other solution (recommanded) is to use the method "SMTP socket library" that has no disadvantages.
|
SendmailOptionMayHurtBuggedMTA=Feature to send mails using method "PHP mail direct" will generate a mail message that might be not correctly parsed by some receiving mail servers. Result is that some mails can't be read by people hosted by those bugged platforms. It's case for some Internet providers (Ex: Orange in France). This is not a problem into Dolibarr nor into PHP but onto receiving mail server. You can however add option MAIN_FIX_FOR_BUGGED_MTA to 1 into setup - other to modify Dolibarr to avoid this. However, you may experience problem with other servers that respect strictly the SMTP standard. The other solution (recommended) is to use the method "SMTP socket library" that has no disadvantages.
|
||||||
TranslationSetup=Configuration de la traduction
|
TranslationSetup=Configuration de la traduction
|
||||||
TranslationDesc=Choice of language visible on screen can be modified:<br>* Globally from menu <strong>Home - Setup - Display</strong><br>* For user only from tab <strong>User display</strong> of user card (click on login on top of screen).
|
TranslationDesc=Choice of language visible on screen can be modified:<br>* Globally from menu <strong>Home - Setup - Display</strong><br>* For user only from tab <strong>User display</strong> of user card (click on login on top of screen).
|
||||||
TotalNumberOfActivatedModules=Total number of activated feature modules: <b>%s</b>
|
TotalNumberOfActivatedModules=Total number of activated feature modules: <b>%s</b>
|
||||||
@ -1417,7 +1417,7 @@ AdvancedEditor=Advanced editor
|
|||||||
ActivateFCKeditor=Activate advanced editor for:
|
ActivateFCKeditor=Activate advanced editor for:
|
||||||
FCKeditorForCompany=WYSIWIG creation/edition of elements description and note (except products/services)
|
FCKeditorForCompany=WYSIWIG creation/edition of elements description and note (except products/services)
|
||||||
FCKeditorForProduct=WYSIWIG creation/edition of products/services description and note
|
FCKeditorForProduct=WYSIWIG creation/edition of products/services description and note
|
||||||
FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). <font class="warning">Warning: Using this option for this case is seriously not recommanded as it can create problems with special characters and page formating when building PDF files.</font>
|
FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). <font class="warning">Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formating when building PDF files.</font>
|
||||||
FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing)
|
FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing)
|
||||||
FCKeditorForUserSignature=WYSIWIG creation/edition of user signature
|
FCKeditorForUserSignature=WYSIWIG creation/edition of user signature
|
||||||
FCKeditorForMail=WYSIWIG creation/edition for all mail (except Outils->eMailing)
|
FCKeditorForMail=WYSIWIG creation/edition for all mail (except Outils->eMailing)
|
||||||
|
|||||||
@ -260,6 +260,7 @@ days=days
|
|||||||
Hours=Hours
|
Hours=Hours
|
||||||
Minutes=Minutes
|
Minutes=Minutes
|
||||||
Seconds=Seconds
|
Seconds=Seconds
|
||||||
|
Weeks=Weeks
|
||||||
Today=Today
|
Today=Today
|
||||||
Yesterday=Yesterday
|
Yesterday=Yesterday
|
||||||
Tomorrow=Tomorrow
|
Tomorrow=Tomorrow
|
||||||
@ -685,6 +686,7 @@ XMoreLines=%s line(s) hidden
|
|||||||
PublicUrl=Public URL
|
PublicUrl=Public URL
|
||||||
AddBox=Add box
|
AddBox=Add box
|
||||||
SelectElementAndClickRefresh=Select an element and click Refresh
|
SelectElementAndClickRefresh=Select an element and click Refresh
|
||||||
|
PrintFile=Print File %s
|
||||||
# Week day
|
# Week day
|
||||||
Monday=Monday
|
Monday=Monday
|
||||||
Tuesday=Tuesday
|
Tuesday=Tuesday
|
||||||
|
|||||||
25
htdocs/langs/en_US/printgcp.lang
Normal file
25
htdocs/langs/en_US/printgcp.lang
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Dolibarr language file - Source file is en_US - printgccp
|
||||||
|
PRINTGCP=Google Cloud Print
|
||||||
|
PrintGCPDesc=This driver allow to send documents directly to a printer with Google Cloud Print.
|
||||||
|
PrintingDriverDescprintgcp=Configuration variables for printing driver Google Cloud Print.
|
||||||
|
PrintTestDescprintgcp=List of Printers for Google Cloud Print.
|
||||||
|
PRINTGCP_LOGIN=Google Account Login
|
||||||
|
PRINTGCP_PASSWORD=Google Account Password
|
||||||
|
STATE_ONLINE=Online
|
||||||
|
STATE_UNKNOWN=Unknown
|
||||||
|
STATE_OFFLINE=Offline
|
||||||
|
STATE_DORMANT=Offline for quite a while
|
||||||
|
TYPE_GOOGLE=Google
|
||||||
|
TYPE_HP=HP Printer
|
||||||
|
TYPE_DOCS=DOCS
|
||||||
|
TYPE_DRIVE=Google Drive
|
||||||
|
TYPE_FEDEX=Fedex
|
||||||
|
TYPE_ANDROID_CHROME_SNAPSHOT=Android
|
||||||
|
TYPE_IOS_CHROME_SNAPSHOT=IOS
|
||||||
|
GCP_Name=Name
|
||||||
|
GCP_displayName=Display Name
|
||||||
|
GCP_Id=Printer Id
|
||||||
|
GCP_OwnerName=Owner Name
|
||||||
|
GCP_State=Printer State
|
||||||
|
GCP_connectionStatus=Online State
|
||||||
|
GCP_Type=Printer Type
|
||||||
10
htdocs/langs/en_US/printing.lang
Normal file
10
htdocs/langs/en_US/printing.lang
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Dolibarr language file - Source file is en_US - printing
|
||||||
|
PrintingSetup=Setup of Printing System
|
||||||
|
PrintingDesc=This module adds a Print button to send documents directly to a printer with various module.
|
||||||
|
ModuleDriverSetup=Setup Module Driver
|
||||||
|
PrintingDriverDesc=Configuration variables for printing driver.
|
||||||
|
ListDrivers=List of drivers
|
||||||
|
PrintTestDesc=List of Printers.
|
||||||
|
FileWasSentToPrinter=File %s was sent to printer
|
||||||
|
NoActivePrintingModuleFound=No active module to print document
|
||||||
|
PleaseSelectaDriverfromList=Please select a driver from list.
|
||||||
@ -1,6 +1,9 @@
|
|||||||
# Dolibarr language file - Source file is en_US - printipp
|
# Dolibarr language file - Source file is en_US - printipp
|
||||||
|
PRINTIPP=PrintIPP Driver
|
||||||
PrintIPPSetup=Setup of Direct Print module
|
PrintIPPSetup=Setup of Direct Print module
|
||||||
PrintIPPDesc=This module adds a Print button to send documents directly to a printer. It requires a Linux system with CUPS installed.
|
PrintIPPDesc=This driver allow to send documents directly to a printer. It requires a Linux system with CUPS installed.
|
||||||
|
PrintingDriverDescprintipp=Configuration variables for printing driver PrintIPP.
|
||||||
|
PrintTestDescprintipp=List of Printers for driver PrintIPP.
|
||||||
PRINTIPP_ENABLED=Show "Direct print" icon in document lists
|
PRINTIPP_ENABLED=Show "Direct print" icon in document lists
|
||||||
PRINTIPP_HOST=Print server
|
PRINTIPP_HOST=Print server
|
||||||
PRINTIPP_PORT=Port
|
PRINTIPP_PORT=Port
|
||||||
@ -12,3 +15,23 @@ NoDefaultPrinterDefined=No default printer defined
|
|||||||
DefaultPrinter=Default printer
|
DefaultPrinter=Default printer
|
||||||
Printer=Printer
|
Printer=Printer
|
||||||
CupsServer=CUPS Server
|
CupsServer=CUPS Server
|
||||||
|
IPP_Uri=Printer Uri
|
||||||
|
IPP_Name=Printer Name
|
||||||
|
IPP_State=Printer State
|
||||||
|
IPP_State_reason=State reason
|
||||||
|
IPP_State_reason1=State reason1
|
||||||
|
IPP_BW=BW
|
||||||
|
IPP_Color=Color
|
||||||
|
IPP_Device=Device
|
||||||
|
IPP_Media=Printer media
|
||||||
|
IPP_Supported=Type of media
|
||||||
|
STATE_IPP_idle=Idle
|
||||||
|
STATE_IPP_stopped=Stopped
|
||||||
|
STATE_IPP_paused=Paused
|
||||||
|
STATE_IPP_toner-low-report=Low Toner
|
||||||
|
STATE_IPP_none=None
|
||||||
|
MEDIA_IPP_stationery=Stationery
|
||||||
|
MEDIA_IPP_thermal=Thermal
|
||||||
|
IPP_COLOR_print-black=BW Printer
|
||||||
|
IPP_COLOR_print-color=Color Printer
|
||||||
|
IPP_COLOR_=No
|
||||||
|
|||||||
@ -736,7 +736,7 @@ if ((! empty($conf->browser->layout) && $conf->browser->layout == 'phone')
|
|||||||
// If we force to use jmobile, then we reenable javascript
|
// If we force to use jmobile, then we reenable javascript
|
||||||
if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1;
|
if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1;
|
||||||
// Replace themes bugged with jmobile with eldy
|
// Replace themes bugged with jmobile with eldy
|
||||||
if (! empty($conf->dol_use_jmobile) && in_array($conf->theme,array('bureau2crea','cameleo')))
|
if (! empty($conf->dol_use_jmobile) && in_array($conf->theme,array('bureau2crea','cameleo','amarok')))
|
||||||
{
|
{
|
||||||
$conf->theme='eldy';
|
$conf->theme='eldy';
|
||||||
$conf->css = "/theme/".$conf->theme."/style.css.php";
|
$conf->css = "/theme/".$conf->theme."/style.css.php";
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||||
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,5 +22,15 @@
|
|||||||
* \brief Page d'index du module margin
|
* \brief Page d'index du module margin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require 'productMargins.php';
|
require '../main.inc.php';
|
||||||
|
|
||||||
|
if ($user->rights->produit->lire) {
|
||||||
|
$page = 'productMargins';
|
||||||
|
} elseif ($user->rights->societe->lire) {
|
||||||
|
$page = 'customerMargins';
|
||||||
|
} else {
|
||||||
|
$page = 'agentMargins';
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Location: '.dol_buildpath('/margin/'.$page.'.php', 1));
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||||
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -56,21 +57,25 @@ function marges_admin_prepare_head()
|
|||||||
*/
|
*/
|
||||||
function marges_prepare_head()
|
function marges_prepare_head()
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs, $conf, $user;
|
||||||
$langs->load("marges@marges");
|
$langs->load("marges@marges");
|
||||||
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
$head = array();
|
$head = array();
|
||||||
|
|
||||||
|
if ($user->rights->produit->lire) {
|
||||||
$head[$h][0] = DOL_URL_ROOT."/margin/productMargins.php";
|
$head[$h][0] = DOL_URL_ROOT."/margin/productMargins.php";
|
||||||
$head[$h][1] = $langs->trans("ProductMargins");
|
$head[$h][1] = $langs->trans("ProductMargins");
|
||||||
$head[$h][2] = 'productMargins';
|
$head[$h][2] = 'productMargins';
|
||||||
$h++;
|
$h++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->rights->societe->lire) {
|
||||||
$head[$h][0] = DOL_URL_ROOT."/margin/customerMargins.php";
|
$head[$h][0] = DOL_URL_ROOT."/margin/customerMargins.php";
|
||||||
$head[$h][1] = $langs->trans("CustomerMargins");
|
$head[$h][1] = $langs->trans("CustomerMargins");
|
||||||
$head[$h][2] = 'customerMargins';
|
$head[$h][2] = 'customerMargins';
|
||||||
$h++;
|
$h++;
|
||||||
|
}
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/margin/agentMargins.php";
|
$head[$h][0] = DOL_URL_ROOT."/margin/agentMargins.php";
|
||||||
$head[$h][1] = $langs->trans("SalesRepresentativeMargins");
|
$head[$h][1] = $langs->trans("SalesRepresentativeMargins");
|
||||||
|
|||||||
0
htdocs/printing/admin/index.html
Normal file
0
htdocs/printing/admin/index.html
Normal file
277
htdocs/printing/admin/printing.php
Normal file
277
htdocs/printing/admin/printing.php
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/printing/admin/printing.php
|
||||||
|
* \ingroup printing
|
||||||
|
* \brief Page to setup printing module
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/printing/lib/printing.lib.php';
|
||||||
|
|
||||||
|
$langs->load("admin");
|
||||||
|
$langs->load("printing");
|
||||||
|
|
||||||
|
if (! $user->admin) accessforbidden();
|
||||||
|
|
||||||
|
$action = GETPOST('action','alpha');
|
||||||
|
$mode = GETPOST('mode','alpha');
|
||||||
|
$value = GETPOST('value','alpha');
|
||||||
|
$varname = GETPOST('varname', 'alpha');
|
||||||
|
$driver = GETPOST('driver', 'alpha');
|
||||||
|
|
||||||
|
if (! empty($driver)) $langs->load($driver);
|
||||||
|
|
||||||
|
if (!$mode) $mode='config';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Action
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (($mode == 'test' || $mode == 'setup') && empty($driver))
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans('PleaseSelectaDriverfromList'));
|
||||||
|
header("Location: ".$_SERVER['PHP_SELF'].'?mode=config');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'setconst' && $user->admin)
|
||||||
|
{
|
||||||
|
$error=0;
|
||||||
|
$db->begin();
|
||||||
|
foreach ($_POST['setupdriver'] as $setupconst) {
|
||||||
|
//print '<pre>'.print_r($setupconst, true).'</pre>';
|
||||||
|
$result=dolibarr_set_const($db, $setupconst['varname'],$setupconst['value'],'chaine',0,'',$conf->entity);
|
||||||
|
if (! $result > 0) $error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
setEventMessage($langs->trans("SetupSaved"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'setvalue' && $user->admin)
|
||||||
|
{
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$result=dolibarr_set_const($db, $varname, $value,'chaine',0,'',$conf->entity);
|
||||||
|
if (! $result > 0) $error++;
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
setEventMessage($langs->trans("SetupSaved"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
llxHeader('',$langs->trans("PrintingSetup"));
|
||||||
|
|
||||||
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
|
print_fiche_titre($langs->trans("PrintingSetup"),$linkback,'setup');
|
||||||
|
|
||||||
|
$head=printingadmin_prepare_head();
|
||||||
|
|
||||||
|
if ($mode == 'setup' && $user->admin)
|
||||||
|
{
|
||||||
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&driver='.$driver.'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="setconst">';
|
||||||
|
|
||||||
|
dol_fiche_head($head, $mode, $langs->trans("ModuleDriverSetup"), 0, 'technic');
|
||||||
|
|
||||||
|
print $langs->trans("PrintingDriverDesc".$driver)."<br><br>\n";
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">'."\n";
|
||||||
|
$var=true;
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<th>'.$langs->trans("Parameters").'</th>';
|
||||||
|
print '<th>'.$langs->trans("Value").'</th>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
if (! empty($driver)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
||||||
|
$classname = 'printing_'.$driver;
|
||||||
|
$langs->load($driver);
|
||||||
|
$printer = new $classname($db);
|
||||||
|
//print '<pre>'.print_r($printer, true).'</pre>';
|
||||||
|
$i=0;
|
||||||
|
foreach ($printer->conf as $key) {
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td'.($key['required']?' class=required':'').'>'.$langs->trans($key['varname']).'</td><td>';
|
||||||
|
print '<input size="32" type="'.(empty($key['type'])?'text':$key['type']).'" name="setupdriver['.$i.'][value]" value="'.$conf->global->{$key['varname']}.'">';
|
||||||
|
print '<input type="hidden" name="setupdriver['.$i.'][varname]" value="'.$key['varname'].'">';
|
||||||
|
print ' '.($key['example']!=''?$langs->trans("Example").' : '.$key['example']:'');
|
||||||
|
print '</tr>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print $langs->trans('PleaseSelectaDriverfromList');
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
if (! empty($driver)) {
|
||||||
|
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></center>';
|
||||||
|
}
|
||||||
|
print '</form>';
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
}
|
||||||
|
if ($mode == 'config' && $user->admin)
|
||||||
|
{
|
||||||
|
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
||||||
|
|
||||||
|
print $langs->trans("PrintingDesc")."<br><br>\n";
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">'."\n";
|
||||||
|
|
||||||
|
$var=true;
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<th>'.$langs->trans("Description").'</th>';
|
||||||
|
print '<th class="center">'.$langs->trans("Active").'</th>';
|
||||||
|
print '<th class="center">'.$langs->trans("Setup").'</th>';
|
||||||
|
print '<th class="center">'.$langs->trans("Test").'</th>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
$object = new PrintingDriver($db);
|
||||||
|
$result = $object->listDrivers($db, 10);
|
||||||
|
foreach ($result as $driver) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
||||||
|
$classname = 'printing_'.$driver;
|
||||||
|
$langs->load($driver);
|
||||||
|
$printer = new $classname($db);
|
||||||
|
//print '<pre>'.print_r($printer, true).'</pre>';
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.img_picto('', $printer->picto).$langs->trans($printer->desc).'</td>';
|
||||||
|
print '<td class="center">';
|
||||||
|
if (! empty($conf->use_javascript_ajax))
|
||||||
|
{
|
||||||
|
print ajax_constantonoff($printer->active);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (empty($conf->global->{$printer->conf}))
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&varname='.$printer->active.'&value=1">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&varname='.$printer->active.'&value=0">'.img_picto($langs->trans("Enabled"),'on').'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?mode=setup&driver='.$printer->name.'">'.img_picto('', 'setup').'</a></td>';
|
||||||
|
print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?mode=test&driver='.$printer->name.'">'.img_picto('', 'setup').'</a></td>';
|
||||||
|
print '</tr>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mode == 'test' && $user->admin)
|
||||||
|
{
|
||||||
|
dol_fiche_head($head, $mode, $langs->trans("PrintingTest"), 0, 'technic');
|
||||||
|
|
||||||
|
print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
if (! empty($driver)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
||||||
|
$classname = 'printing_'.$driver;
|
||||||
|
$langs->load($driver);
|
||||||
|
$printer = new $classname($db);
|
||||||
|
//print '<pre>'.print_r($printer, true).'</pre>';
|
||||||
|
print $printer->listAvailablePrinters();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
print $langs->trans('PleaseSelectaDriverfromList');
|
||||||
|
}
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mode == 'userconf' && $user->admin)
|
||||||
|
{
|
||||||
|
dol_fiche_head($head, $mode, $langs->trans("UserConf"), 0, 'technic');
|
||||||
|
|
||||||
|
print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n";
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
$var=true;
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<th>'.$langs->trans("User").'</th>';
|
||||||
|
print '<th>'.$langs->trans("PrintModule").'</th>';
|
||||||
|
print '<th>'.$langs->trans("PrintDriver").'</th>';
|
||||||
|
print '<th>'.$langs->trans("Printer").'</th>';
|
||||||
|
print '<th>'.$langs->trans("PrinterLocation").'</th>';
|
||||||
|
print '<th>'.$langs->trans("PrinterId").'</th>';
|
||||||
|
print '<th>'.$langs->trans("NumberOfCopy").'</th>';
|
||||||
|
print '<th class="center">'.$langs->trans("Delete").'</th>';
|
||||||
|
print "</tr>\n";
|
||||||
|
$sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid';
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
while ($row=$db->fetch_array($resql)) {
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$row['login'].'</td>';
|
||||||
|
print '<td>'.$row['module'].'</td>';
|
||||||
|
print '<td>'.$row['driver'].'</td>';
|
||||||
|
print '<td>'.$row['printer_name'].'</td>';
|
||||||
|
print '<td>'.$row['printer_location'].'</td>';
|
||||||
|
print '<td>'.$row['printer_id'].'</td>';
|
||||||
|
print '<td>'.$row['copy'].'</td>';
|
||||||
|
print '<td class="center">'.img_picto($langs->trans("Delete"), 'delete').'</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
}
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
|
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,20 +17,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/printipp/index.php
|
* \file htdocs/printing/index.php
|
||||||
* \ingroup printipp
|
* \ingroup printing
|
||||||
* \brief Printipp
|
* \brief Printing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php';
|
||||||
|
|
||||||
llxHeader("",$langs->trans("Printer"));
|
llxHeader("",$langs->trans("Printing"));
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("Printer"));
|
print_fiche_titre($langs->trans("Printing"));
|
||||||
|
|
||||||
$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD);
|
// List Jobs from printing modules
|
||||||
$printer->list_jobs('commande');
|
//$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD);
|
||||||
|
//$printer->list_jobs('commande');
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
0
htdocs/printing/lib/index.html
Normal file
0
htdocs/printing/lib/index.html
Normal file
@ -16,44 +16,54 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/printipp/lib/printipp.lib.php
|
* \file htdocs/printing/lib/printing.lib.php
|
||||||
* \ingroup printipp
|
* \ingroup printing
|
||||||
* \brief Library for printipp functions
|
* \brief Library for printing functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define head array for tabs of printipp tools setup pages
|
* Define head array for tabs of printing tools setup pages
|
||||||
*
|
*
|
||||||
* @return Array of head
|
* @return Array of head
|
||||||
*/
|
*/
|
||||||
function printippadmin_prepare_head()
|
function printingadmin_prepare_head()
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
$head = array();
|
$head = array();
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/printipp/admin/printipp.php?mode=config";
|
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=config";
|
||||||
$head[$h][1] = $langs->trans("CupsServer");
|
$head[$h][1] = $langs->trans("ListDrivers");
|
||||||
$head[$h][2] = 'config';
|
$head[$h][2] = 'config';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/printipp/admin/printipp.php?mode=test";
|
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup";
|
||||||
$head[$h][1] = $langs->trans("Printer");
|
$head[$h][1] = $langs->trans("SetupDriver");
|
||||||
|
$head[$h][2] = 'setup';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test";
|
||||||
|
$head[$h][1] = $langs->trans("TestDriver");
|
||||||
$head[$h][2] = 'test';
|
$head[$h][2] = 'test';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
$object=new stdClass();
|
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=userconf";
|
||||||
|
$head[$h][1] = $langs->trans("UserConf");
|
||||||
|
$head[$h][2] = 'userconf';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
//$object=new stdClass();
|
||||||
|
|
||||||
// Show more tabs from modules
|
// Show more tabs from modules
|
||||||
// Entries must be declared in modules descriptor with line
|
// Entries must be declared in modules descriptor with line
|
||||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'printippadmin');
|
//complete_head_from_modules($conf,$langs,$object,$head,$h,'printingadmin');
|
||||||
|
|
||||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'printipp','remove');
|
//complete_head_from_modules($conf,$langs,$object,$head,$h,'printing','remove');
|
||||||
|
|
||||||
return $head;
|
return $head;
|
||||||
}
|
}
|
||||||
@ -1,246 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/printipp/admin/printipp.php
|
|
||||||
* \ingroup printipp
|
|
||||||
* \brief Page to setup printipp module
|
|
||||||
*/
|
|
||||||
|
|
||||||
require '../../main.inc.php';
|
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/printipp/lib/printipp.lib.php';
|
|
||||||
|
|
||||||
$langs->load("admin");
|
|
||||||
$langs->load("printipp");
|
|
||||||
|
|
||||||
if (! $user->admin) accessforbidden();
|
|
||||||
|
|
||||||
$action = GETPOST('action','alpha');
|
|
||||||
$mode = GETPOST('mode','alpha');
|
|
||||||
$value = GETPOST('value','alpha');
|
|
||||||
|
|
||||||
if (!$mode) $mode='config';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Action
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($action == 'setvalue' && $user->admin)
|
|
||||||
{
|
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
if (! $result > 0) $error++;
|
|
||||||
$result=dolibarr_set_const($db, "PRINTIPP_HOST",GETPOST('PRINTIPP_HOST','alpha'),'chaine',0,'',$conf->entity);
|
|
||||||
if (! $result > 0) $error++;
|
|
||||||
$result=dolibarr_set_const($db, "PRINTIPP_PORT",GETPOST('PRINTIPP_PORT','alpha'),'chaine',0,'',$conf->entity);
|
|
||||||
if (! $result > 0) $error++;
|
|
||||||
$result=dolibarr_set_const($db, "PRINTIPP_USER",GETPOST('PRINTIPP_USER','alpha'),'chaine',0,'',$conf->entity);
|
|
||||||
if (! $result > 0) $error++;
|
|
||||||
$result=dolibarr_set_const($db, "PRINTIPP_PASSWORD",GETPOST('PRINTIPP_PASSWORD','alpha'),'chaine',0,'',$conf->entity);
|
|
||||||
if (! $result > 0) $error++;
|
|
||||||
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
$db->commit();
|
|
||||||
setEventMessage($langs->trans("SetupSaved"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$db->rollback();
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set default model
|
|
||||||
else if ($action == 'setprinteruri')
|
|
||||||
{
|
|
||||||
if (dolibarr_set_const($db, "PRINTIPP_URI_DEFAULT",$value,'chaine',0,'',$conf->entity))
|
|
||||||
{
|
|
||||||
// La constante qui a ete lue en avant du nouveau set
|
|
||||||
// on passe donc par une variable pour avoir un affichage coherent
|
|
||||||
$conf->global->PRINTIPP_URI_DEFAULT = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* View
|
|
||||||
*/
|
|
||||||
|
|
||||||
$form = new Form($db);
|
|
||||||
|
|
||||||
llxHeader('',$langs->trans("PrintIPPSetup"));
|
|
||||||
|
|
||||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
|
||||||
print_fiche_titre($langs->trans("PrintIPPSetup"),$linkback,'setup');
|
|
||||||
|
|
||||||
$head=printippadmin_prepare_head();
|
|
||||||
|
|
||||||
|
|
||||||
if ($mode == 'config' && $user->admin)
|
|
||||||
{
|
|
||||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=config">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
print '<input type="hidden" name="action" value="setvalue">';
|
|
||||||
|
|
||||||
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
|
||||||
|
|
||||||
print $langs->trans("PrintIPPDesc")."<br><br>\n";
|
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
|
|
||||||
$var=true;
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td>'.$langs->trans("Parameters").'</td>';
|
|
||||||
print '<td>'.$langs->trans("Value").'</td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
/*
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'><td>';
|
|
||||||
print $langs->trans("PRINTIPP_ENABLED").'</td><td colspan="2" align="left">';
|
|
||||||
|
|
||||||
if (! empty($conf->use_javascript_ajax))
|
|
||||||
{
|
|
||||||
print ajax_constantonoff('PRINTIPP_ENABLED');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (empty($conf->global->PRINTIPP_ENABLED))
|
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_PRINTIPP_ENABLED">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_PRINTIPP_ENABLED">'.img_picto($langs->trans("Enabled"),'on').'</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
|
||||||
*/
|
|
||||||
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'><td class="fieldrequired">';
|
|
||||||
print $langs->trans("PRINTIPP_HOST").'</td><td>';
|
|
||||||
print '<input size="64" type="text" name="PRINTIPP_HOST" value="'.$conf->global->PRINTIPP_HOST.'">';
|
|
||||||
print ' '.$langs->trans("Example").': localhost';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'><td class="fieldrequired">';
|
|
||||||
print $langs->trans("PRINTIPP_PORT").'</td><td>';
|
|
||||||
print '<input size="32" type="text" name="PRINTIPP_PORT" value="'.$conf->global->PRINTIPP_PORT.'">';
|
|
||||||
print ' '.$langs->trans("Example").': 631';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'><td>';
|
|
||||||
print $langs->trans("PRINTIPP_USER").'</td><td>';
|
|
||||||
print '<input size="32" type="text" name="PRINTIPP_USER" value="'.$conf->global->PRINTIPP_USER.'">';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'><td>';
|
|
||||||
print $langs->trans("PRINTIPP_PASSWORD").'</td><td>';
|
|
||||||
print '<input size="32" type="text" name="PRINTIPP_PASSWORD" value="'.$conf->global->PRINTIPP_PASSWORD.'">';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
//$var=true;
|
|
||||||
//print '<tr class="liste_titre">';
|
|
||||||
//print '<td>'.$langs->trans("OtherParameter").'</td>';
|
|
||||||
//print '<td>'.$langs->trans("Value").'</td>';
|
|
||||||
//print "</tr>\n";
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
dol_fiche_end();
|
|
||||||
|
|
||||||
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></center>';
|
|
||||||
|
|
||||||
print '</form>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($mode == 'test' && $user->admin)
|
|
||||||
{
|
|
||||||
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
|
||||||
|
|
||||||
print $langs->trans("PrintIPPDesc")."<br><br>\n";
|
|
||||||
|
|
||||||
print '<table class="nobordernopadding" width="100%">';
|
|
||||||
$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD);
|
|
||||||
$var=true;
|
|
||||||
print '<table width="100%" class="noborder">';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td>Uri</td>';
|
|
||||||
print '<td>Name</td>';
|
|
||||||
print '<td>State</td>';
|
|
||||||
print '<td>State_reason</td>';
|
|
||||||
print '<td>State_reason1</td>';
|
|
||||||
print '<td>BW</td>';
|
|
||||||
print '<td>Color</td>';
|
|
||||||
//print '<td>Device</td>';
|
|
||||||
print '<td>Media</td>';
|
|
||||||
print '<td>Supported</td>';
|
|
||||||
print '<td>'.$langs->trans("Select").'</td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
$list = $printer->getlist_available_printers();
|
|
||||||
$var = true;
|
|
||||||
foreach ($list as $value)
|
|
||||||
{
|
|
||||||
$var=!$var;
|
|
||||||
$printer_det = $printer->get_printer_detail($value);
|
|
||||||
print "<tr ".$bc[$var].">";
|
|
||||||
print '<td>'.$value.'</td>';
|
|
||||||
//print '<td><pre>'.print_r($printer_det,true).'</pre></td>';
|
|
||||||
print '<td>'.$printer_det->printer_name->_value0.'</td>';
|
|
||||||
print '<td>'.$printer_det->printer_state->_value0.'</td>';
|
|
||||||
print '<td>'.$printer_det->printer_state_reasons->_value0.'</td>';
|
|
||||||
print '<td>'.$printer_det->printer_state_reasons->_value1.'</td>';
|
|
||||||
print '<td>'.$printer_det->printer_type->_value2.'</td>';
|
|
||||||
print '<td>'.$printer_det->printer_type->_value3.'</td>';
|
|
||||||
//print '<td>'.$printer_det->device_uri->_value0.'</td>';
|
|
||||||
print '<td>'.$printer_det->media_default->_value0.'</td>';
|
|
||||||
print '<td>'.$printer_det->media_type_supported->_value1.'</td>';
|
|
||||||
// Defaut
|
|
||||||
print "<td align=\"center\">";
|
|
||||||
if ($conf->global->PRINTIPP_URI_DEFAULT == "$value")
|
|
||||||
{
|
|
||||||
print img_picto($langs->trans("Default"),'on');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setprinteruri&mode=test&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
}
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
if (count($list) == 0) print $langs->trans("NoPrinterFound");
|
|
||||||
|
|
||||||
dol_fiche_end();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
@ -73,16 +73,20 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
$modulepart='produit';
|
$modulepart='produit';
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
$parameters=array('id'=>$id);
|
$parameters=array('id'=>$id);
|
||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
/*
|
{
|
||||||
* Action envoie fichier
|
// Action sending file
|
||||||
*/
|
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -81,6 +81,8 @@ $parameters=array('socid'=>$socid, 'id_prod'=>$id);
|
|||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
if ($action == 'remove_pf')
|
if ($action == 'remove_pf')
|
||||||
{
|
{
|
||||||
$product = new ProductFournisseur($db);
|
$product = new ProductFournisseur($db);
|
||||||
@ -181,6 +183,7 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
|
|||||||
$ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, $npr);
|
$ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, $npr);
|
||||||
if ($ret < 0)
|
if ($ret < 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessage($product->error, 'errors');
|
setEventMessage($product->error, 'errors');
|
||||||
}
|
}
|
||||||
@ -224,7 +227,7 @@ if (GETPOST('cancel') == $langs->trans("Cancel"))
|
|||||||
header("Location: fournisseurs.php?id=".$_GET["id"]);
|
header("Location: fournisseurs.php?id=".$_GET["id"]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -398,7 +401,8 @@ if ($id || $ref)
|
|||||||
print '<input type="text" class="flat" size="5" name="tva_tx" value="'.(GETPOST("tva_tx")?vatrate(GETPOST("tva_tx")):($default_vat!=''?vatrate($default_vat):'')).'">';
|
print '<input type="text" class="flat" size="5" name="tva_tx" value="'.(GETPOST("tva_tx")?vatrate(GETPOST("tva_tx")):($default_vat!=''?vatrate($default_vat):'')).'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
if (! empty($conf->dynamicprices->enabled)) { //Only show price mode and expression selector if module is enabled
|
if (! empty($conf->dynamicprices->enabled)) //Only show price mode and expression selector if module is enabled
|
||||||
|
{
|
||||||
// Price mode selector
|
// Price mode selector
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("PriceMode").'</td><td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("PriceMode").'</td><td>';
|
||||||
$price_expression = new PriceExpression($db);
|
$price_expression = new PriceExpression($db);
|
||||||
@ -467,7 +471,7 @@ if ($id || $ref)
|
|||||||
|
|
||||||
print '<br><div class="center">';
|
print '<br><div class="center">';
|
||||||
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|||||||
@ -145,12 +145,12 @@ print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'
|
|||||||
|
|
||||||
// Date start
|
// Date start
|
||||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
||||||
print dol_print_date($object->date_start,'day');
|
print dol_print_date($project->date_start,'day');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Date end
|
// Date end
|
||||||
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
|
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
|
||||||
print dol_print_date($object->date_end,'day');
|
print dol_print_date($project->date_end,'day');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
@ -62,11 +62,10 @@ $parameters=array('resource_id'=>$id);
|
|||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* ACTIONS
|
* ACTIONS
|
||||||
*
|
|
||||||
* Put here all code to do according to value of "action" parameter
|
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write )
|
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write )
|
||||||
@ -76,7 +75,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write
|
|||||||
if (empty($ref))
|
if (empty($ref))
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")), 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -96,7 +95,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessage('<div class="error">'.$object->error.'</div>');
|
setEventMessage($object->error, 'errors');
|
||||||
$action='edit';
|
$action='edit';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +111,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write
|
|||||||
$action='edit';
|
$action='edit';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
* VIEW
|
* VIEW
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
|
# @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
|
||||||
# @copyright GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro
|
# @copyright GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro
|
||||||
|
|
||||||
#
|
#
|
||||||
|
# Convert an ODT into a PDF using "jodconverter" tool.
|
||||||
|
# Dolibarr variable MAIN_ODT_AS_PDF must be defined to have this script called after ODT generation.
|
||||||
|
# Dolibarr variable MAIN_DOL_SCRIPTS_ROOT must be defined to path of script directories (otherwise dolibarr will try to guess).
|
||||||
|
|
||||||
|
|
||||||
#if [ -f "$1.odt" ]
|
#if [ -f "$1.odt" ]
|
||||||
# then
|
# then
|
||||||
# soffice --invisible --convert-to pdf:writer_pdf_Export --outdir $2 "$1.odt"
|
# soffice --invisible --convert-to pdf:writer_pdf_Export --outdir $2 "$1.odt"
|
||||||
|
|||||||
@ -216,7 +216,7 @@ class FactureTest extends PHPUnit_Framework_TestCase
|
|||||||
$newlocalobject=new Facture($this->savdb);
|
$newlocalobject=new Facture($this->savdb);
|
||||||
$newlocalobject->initAsSpecimen();
|
$newlocalobject->initAsSpecimen();
|
||||||
$this->changeProperties($newlocalobject);
|
$this->changeProperties($newlocalobject);
|
||||||
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc')), array()); // Actual, Expected
|
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final')), array()); // Actual, Expected
|
||||||
|
|
||||||
return $localobject;
|
return $localobject;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -215,9 +215,9 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
|||||||
$newlocalobject=new Facture($this->savdb);
|
$newlocalobject=new Facture($this->savdb);
|
||||||
$newlocalobject->fetch($invoiceid);
|
$newlocalobject->fetch($invoiceid);
|
||||||
|
|
||||||
$this->assertEquals(2.48,$newlocalobject->total_ht);
|
$this->assertEquals(2.48,$newlocalobject->total_ht, "testUpdatePrice test1");
|
||||||
$this->assertEquals(0.24,$newlocalobject->total_tva);
|
$this->assertEquals(0.24,$newlocalobject->total_tva, "testUpdatePrice test2");
|
||||||
$this->assertEquals(2.72,$newlocalobject->total_ttc);
|
$this->assertEquals(2.72,$newlocalobject->total_ttc, "testUpdatePrice test3");
|
||||||
|
|
||||||
|
|
||||||
// Two lines of 1.24 give 2.48 HT and 2.73 TTC with global vat rounding mode
|
// Two lines of 1.24 give 2.48 HT and 2.73 TTC with global vat rounding mode
|
||||||
@ -231,7 +231,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
|
|||||||
$newlocalobject=new Facture($this->savdb);
|
$newlocalobject=new Facture($this->savdb);
|
||||||
$newlocalobject->fetch($invoiceid);
|
$newlocalobject->fetch($invoiceid);
|
||||||
|
|
||||||
$this->assertEquals(2.48,$newlocalobject->total_ht);
|
$this->assertEquals(2.48,$newlocalobject->total_ht, "testUpdatePrice test4");
|
||||||
//$this->assertEquals(0.25,$newlocalobject->total_tva);
|
//$this->assertEquals(0.25,$newlocalobject->total_tva);
|
||||||
//$this->assertEquals(2.73,$newlocalobject->total_ttc);
|
//$this->assertEquals(2.73,$newlocalobject->total_ttc);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user