version de test
This commit is contained in:
parent
fed00b67c6
commit
2efa632487
2 changed files with 41 additions and 153 deletions
|
@ -18,7 +18,7 @@
|
||||||
/**
|
/**
|
||||||
* \file sendfacrecmail/class/actions_sendfacrecmail.class.php
|
* \file sendfacrecmail/class/actions_sendfacrecmail.class.php
|
||||||
* \ingroup sendfacrecmail
|
* \ingroup sendfacrecmail
|
||||||
* \brief Example hook overload.
|
* \brief Hook overload for SendFacRecEmail
|
||||||
*
|
*
|
||||||
* Put detailed description here.
|
* Put detailed description here.
|
||||||
*/
|
*/
|
||||||
|
@ -28,21 +28,20 @@
|
||||||
*/
|
*/
|
||||||
class Actionssendfacrecmail
|
class Actionssendfacrecmail
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var DoliDB Database handler.
|
* @var DoliDB Database handler.
|
||||||
*/
|
*/
|
||||||
public $db;
|
public $db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Error code (or message)
|
* @var string Error code (or message)
|
||||||
*/
|
*/
|
||||||
public $error = '';
|
public $error = '';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Errors
|
|
||||||
*/
|
|
||||||
public $errors = array();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Errors
|
||||||
|
*/
|
||||||
|
public $errors = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array Hook results. Propagated to $hookmanager->resArray for later reuse
|
* @var array Hook results. Propagated to $hookmanager->resArray for later reuse
|
||||||
|
@ -65,24 +64,6 @@ class Actionssendfacrecmail
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute action
|
|
||||||
*
|
|
||||||
* @param array $parameters Array of parameters
|
|
||||||
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
|
|
||||||
* @param string $action 'add', 'update', 'view'
|
|
||||||
* @return int <0 if KO,
|
|
||||||
* =0 if OK but we want to process standard actions too,
|
|
||||||
* >0 if OK and we want to replace standard actions.
|
|
||||||
*/
|
|
||||||
function getNomUrl($parameters,&$object,&$action)
|
|
||||||
{
|
|
||||||
global $db,$langs,$conf,$user;
|
|
||||||
$this->resprints = '';
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overloading the doActions function : replacing the parent's function with the one below
|
* Overloading the doActions function : replacing the parent's function with the one below
|
||||||
*
|
*
|
||||||
|
@ -98,9 +79,14 @@ class Actionssendfacrecmail
|
||||||
|
|
||||||
$error = 0; // Error counter
|
$error = 0; // Error counter
|
||||||
|
|
||||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
$fp = fopen('/tmp/vardump.txt', 'w');
|
||||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
fwrite($fp, serialize($parameters, $object, $action, $hookmanager));
|
||||||
{
|
fclose($fp);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
||||||
|
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
||||||
|
{
|
||||||
// Do what you want here...
|
// Do what you want here...
|
||||||
// You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values.
|
// You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values.
|
||||||
}
|
}
|
||||||
|
@ -114,131 +100,33 @@ class Actionssendfacrecmail
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function writeSQL($parameters, &$object, &$action, $hookmanager)
|
||||||
|
|
||||||
/**
|
|
||||||
* Overloading the doActions function : replacing the parent's function with the one below
|
|
||||||
*
|
|
||||||
* @param array $parameters Hook metadatas (context, etc...)
|
|
||||||
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
|
|
||||||
* @param string $action Current action (if set). Generally create or edit or null
|
|
||||||
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
|
|
||||||
* @return int < 0 on error, 0 on success, 1 to replace standard code
|
|
||||||
*/
|
|
||||||
public function doMassActions($parameters, &$object, &$action, $hookmanager)
|
|
||||||
{
|
|
||||||
global $conf, $user, $langs;
|
|
||||||
|
|
||||||
$error = 0; // Error counter
|
|
||||||
|
|
||||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
|
||||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
|
||||||
{
|
|
||||||
foreach($parameters['toselect'] as $objectid)
|
|
||||||
{
|
|
||||||
// Do action on each object id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
$this->results = array('myreturn' => 999);
|
|
||||||
$this->resprints = 'A text to show';
|
|
||||||
return 0; // or return 1 to replace standard code
|
|
||||||
} else {
|
|
||||||
$this->errors[] = 'Error message';
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overloading the addMoreMassActions function : replacing the parent's function with the one below
|
|
||||||
*
|
|
||||||
* @param array $parameters Hook metadatas (context, etc...)
|
|
||||||
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
|
|
||||||
* @param string $action Current action (if set). Generally create or edit or null
|
|
||||||
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
|
|
||||||
* @return int < 0 on error, 0 on success, 1 to replace standard code
|
|
||||||
*/
|
|
||||||
public function addMoreMassActions($parameters, &$object, &$action, $hookmanager)
|
|
||||||
{
|
|
||||||
global $conf, $user, $langs;
|
|
||||||
|
|
||||||
$error = 0; // Error counter
|
|
||||||
|
|
||||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
|
||||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
|
||||||
{
|
|
||||||
$this->resprints = '<option value="0"'.($disabled?' disabled="disabled"':'').'>'.$langs->trans("sendfacrecmailMassAction").'</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
return 0; // or return 1 to replace standard code
|
|
||||||
} else {
|
|
||||||
$this->errors[] = 'Error message';
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute action
|
|
||||||
*
|
|
||||||
* @param array $parameters Array of parameters
|
|
||||||
* @param Object $object Object output on PDF
|
|
||||||
* @param string $action 'add', 'update', 'view'
|
|
||||||
* @return int <0 if KO,
|
|
||||||
* =0 if OK but we want to process standard actions too,
|
|
||||||
* >0 if OK and we want to replace standard actions.
|
|
||||||
*/
|
|
||||||
function beforePDFCreation($parameters, &$object, &$action)
|
|
||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
global $hookmanager;
|
|
||||||
|
|
||||||
$outputlangs=$langs;
|
$error = 0; // Error counter
|
||||||
|
//$object = "SELECT rowid FROM llx_facture_rec WHERE false";
|
||||||
|
|
||||||
$ret=0; $deltemp=array();
|
$fp = fopen('/tmp/writesql-vardump.txt', 'w');
|
||||||
dol_syslog(get_class($this).'::executeHooks action='.$action);
|
fwrite($fp, serialize($parameters));
|
||||||
|
fwrite($fp, serialize($object));
|
||||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
fwrite($fp, serialize($action));
|
||||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
fwrite($fp, serialize($hookmanager));
|
||||||
{
|
fclose($fp);
|
||||||
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
public function generatedInvoice($parameters, &$object, &$action, $hookmanager)
|
||||||
/**
|
|
||||||
* Execute action
|
|
||||||
*
|
|
||||||
* @param array $parameters Array of parameters
|
|
||||||
* @param Object $pdfhandler PDF builder handler
|
|
||||||
* @param string $action 'add', 'update', 'view'
|
|
||||||
* @return int <0 if KO,
|
|
||||||
* =0 if OK but we want to process standard actions too,
|
|
||||||
* >0 if OK and we want to replace standard actions.
|
|
||||||
*/
|
|
||||||
function afterPDFCreation($parameters, &$pdfhandler, &$action)
|
|
||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
global $hookmanager;
|
|
||||||
|
|
||||||
$outputlangs=$langs;
|
$error = 0; // Error counter
|
||||||
|
|
||||||
$ret=0; $deltemp=array();
|
$fp = fopen('/tmp/generatedinvoice-vardump.txt', 'w');
|
||||||
dol_syslog(get_class($this).'::executeHooks action='.$action);
|
fwrite($fp, serialize($parameters));
|
||||||
|
fwrite($fp, serialize($object));
|
||||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
fwrite($fp, serialize($action));
|
||||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
fwrite($fp, serialize($hookmanager));
|
||||||
{
|
fclose($fp);
|
||||||
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add here any other hooked methods... */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class modsendfacrecmail extends DolibarrModules
|
||||||
$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
|
$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
|
||||||
$this->langfiles = array("sendfacrecmail@sendfacrecmail");
|
$this->langfiles = array("sendfacrecmail@sendfacrecmail");
|
||||||
//$this->phpmin = array(5,4); // Minimum version of PHP required by module
|
//$this->phpmin = array(5,4); // Minimum version of PHP required by module
|
||||||
$this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module
|
$this->need_dolibarr_version = array(8,9); // Minimum version of Dolibarr required by module
|
||||||
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
|
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
|
||||||
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
|
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
|
||||||
//$this->automatic_activation = array('FR'=>'sendfacrecmailWasAutomaticallyActivatedBecauseOfYourCountryChoice');
|
//$this->automatic_activation = array('FR'=>'sendfacrecmailWasAutomaticallyActivatedBecauseOfYourCountryChoice');
|
||||||
|
|
Loading…
Reference in a new issue