function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
    {
        global $db, $langs;
        if (in_array('ordercard', explode(':', $parameters['context'])) && $object->statut < 3) {
            dol_include_once('/shippableorder/class/shippableorder.class.php');
            $shippableOrder =& $object->shippableorder;
            ?>
			<script type="text/javascript">
				$('table#tablelines tr.liste_titre td.linecoldescription').first().after('<td class="linecolstock" align="right" style="color:#fff;"><?php 
            echo $langs->trans('Available');
            ?>
</td>');				
				<?php 
            foreach ($object->lines as &$line) {
                $stock = $shippableOrder->orderLineStockStatus($line, true);
                ?>
					$('table#tablelines tr[id=row-<?php 
                echo $line->id;
                ?>
] td.linecoldescription').after("<td class=\"linecolstock nowrap\" align=\"right\"><?php 
                echo addslashes($stock);
                ?>
</td>");				
					<?php 
            }
            ?>
			</script>
			<?php 
        }
    }
 /**
  * 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
  */
 function doActions($parameters, &$object, &$action, $hookmanager)
 {
     if (in_array('invoicecard', explode(':', $parameters['context']))) {
         if ($action == 'update_courrier') {
             global $user, $db, $langs;
             $object->array_options['options_courrier_envoi'] = time();
             $object->insertExtraFields();
             dol_include_once('/comm/action/class/actioncomm.class.php');
             $a = new ActionComm($db);
             $a->type_code = 'AC_OTH_AUTO';
             $a->label = $langs->trans('ClassifyCourrierEvent', $object->ref);
             $a->fk_element = $object->id;
             $a->elementtype = 'facture';
             $a->usertodo = $user;
             $a->userdone = $user;
             $a->percentage = 100;
             $a->datep = date('Y-m-d H:i:s');
             $a->add($user);
             setEventMessage('ClassifyCourrierMsg');
         } else {
             if ($action == 'no_courrier') {
                 global $user;
                 $object->array_options['options_courrier_envoi'] = '';
                 $object->insertExtraFields();
                 setEventMessage('UnClassifyCourrierMsg');
             }
         }
     }
     return 0;
 }
 function beforePDFCreation($parameters, &$object, &$action, $hookmanager)
 {
     if ($object->element == 'facture') {
         if (isset($object->thirdparty)) {
             $societe =& $object->thirdparty;
         } else {
             dol_include_once('/societe/class/societe.class.php');
             $societe = new Societe($db);
             $societe->fetch($object->socid);
         }
         if (!empty($societe->id)) {
             global $db, $conf;
             if (!empty($societe->array_options['options_fk_soc_factor']) && $societe->array_options['options_factor_suivi'] == 1) {
                 define('INC_FROM_DOLIBARR', true);
                 dol_include_once('/factor/config.php');
                 dol_include_once('/factor/class/factor.class.php');
                 $PDOdb = new TPDOdb();
                 $factor = new TFactor();
                 $factor->loadBy($PDOdb, $societe->array_options['options_fk_soc_factor'], 'fk_soc');
                 if (!empty($factor->mention)) {
                     if (strpos($object->note_public, $factor->mention) === false) {
                         $object->note_public = $factor->mention . (!empty($object->note_public) ? "\n\n" . $object->note_public : '');
                         $r = $object->update_note($object->note_public, '_public');
                     }
                 }
             }
         }
     }
 }
    /**
     * 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
     */
    function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
    {
        $error = 0;
        if (in_array('pricesuppliercard', explode(':', $parameters['context']))) {
            global $conf, $user, $langs;
            if (!empty($conf->global->MANDARIN_TRACE_COST_PRICE) && !empty($user->rights->mandarin->graph->product_cost_price)) {
                define('INC_FROM_DOLIBARR', true);
                dol_include_once('/mandarin/config.php');
                dol_include_once('/mandarin/class/costpricelog.class.php');
                $PDOdb = new TPDOdb();
                $TData = TProductCostPriceLog::getDataForProduct($PDOdb, $object->id);
                if (!empty($TData)) {
                    $l = new TListviewTBS('graphrate');
                    echo $l->renderArray($PDOdb, $TData, array('type' => 'chart', 'curveType' => 'none', 'liste' => array('titre' => $langs->trans('GraphTraceCostPrice')), 'title' => array('PA' => $langs->transnoentities('PricePA'), 'PMP' => $langs->transnoentities('PricePMP'), 'OF' => $langs->transnoentities('PriceOF'))));
                    ?>
					<script type="text/javascript">
						$(document).ready(function() {
							$('#div_query_chartgraphrate').insertAfter('div.fiche:first');
						});
						
					</script>
					<?php 
                }
            }
        }
        if (!$error) {
            return 0;
            // or return 1 to replace standard code
        } else {
            $this->errors[] = 'Error message';
            return -1;
        }
    }
 static function getRefByObject(&$object)
 {
     global $db;
     $ref = '';
     if ($object->element == 'societe' && !empty($object->code_client)) {
         $ref = $object->code_client;
     } else {
         if ($object->element == 'societe') {
             $ref = $object->name;
         } else {
             if ($object->element == 'contact') {
                 dol_include_once('/societe/class/societe.class.php');
                 $soc = new Societe($db);
                 $soc->fetch($object->socid);
                 $ref = trim((!empty($soc->code_client) ? $soc->code_client : $soc->name) . '_' . $object->lastname);
             } else {
                 if ($object->element == 'user' && !empty($object->login)) {
                     $ref = $object->login;
                 } elseif (!empty($object->ref)) {
                     $ref = $object->ref;
                 }
             }
         }
     }
     return $ref;
 }
Example #6
0
 /**
  * Load data into info_box_contents array to show array later.
  *
  * @param int $max of records to load
  *
  * @return void
  */
 public function loadBox($max = 5)
 {
     global $conf, $user, $langs, $db;
     $this->max = $max;
     dol_include_once('/lead/class/lead.class.php');
     $lead = new Lead($db);
     $lead->fetch_all('DESC', 't.date_closure', $max, 0, array('t.date_closure<' => dol_now()));
     $text = $langs->trans("LeadLate", $max);
     $this->info_box_head = array('text' => $text, 'limit' => dol_strlen($text));
     $i = 0;
     foreach ($lead->lines as $line) {
         // FIXME: line is an array, not an object
         $line->fetch_thirdparty();
         // Ref
         $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id);
         $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $line->ref, 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id);
         $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc);
         $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($line->thirdparty->name, 40), 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc);
         // Amount Guess
         $this->info_box_contents[$i][4] = array('td' => 'align="left"', 'text' => price($line->amount_prosp, 'HTML') . $langs->getCurrencySymbol($conf->currency));
         // Amount real
         $this->info_box_contents[$i][5] = array('td' => 'align="left"', 'text' => $line->getRealAmount() . $langs->getCurrencySymbol($conf->currency));
         $i++;
     }
 }
    function formObjectOptions($parameters, &$object, &$action, $hookmanager)
    {
        global $conf, $langs, $db;
        if ((in_array('ordercard', explode(':', $parameters['context'])) || in_array('propalcard', explode(':', $parameters['context']))) && $conf->global->REMISE_USE_WEIGHT) {
            print '<script type="text/javascript">
	                $(document).ready(function() { ';
            foreach ($object->lines as &$line) {
                if ($line->fk_product_type == 0 && $line->fk_product > 0) {
                    dol_include_once('/product/class/product.class.php', 'Product');
                    $p = new Product($db);
                    $p->fetch($line->fk_product);
                    if ($p->id > 0) {
                        $weight_kg = $p->weight * $line->qty * pow(10, $p->weight_units);
                        $id_line = !empty($line->id) ? $line->id : $line->rowid;
                        if (!empty($weight_kg)) {
                            print '$("tr#row-' . $id_line . ' td:first").append(" - ' . $langs->trans('Weight') . ' : ' . $weight_kg . 'Kg");';
                        }
                    }
                }
            }
            print '});
	        </script>';
        }
        return 0;
    }
    /** Overloading the doActions function : replacing the parent's function with the one below
     *  @param      parameters  meta datas of the hook (context, etc...)
     *  @param      object             the object you want to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
     *  @param      action             current action (if set). Generally create or edit or null
     *  @return       void
     */
    function formObjectOptions($parameters, &$object, &$action, $hookmanager)
    {
        global $user;
        if (($parameters['currentcontext'] == 'projectcard' || $parameters['currentcontext'] == 'productcard' || $parameters['currentcontext'] == 'thirdpartycard' || $parameters['currentcontext'] == 'usercard') && $action == '' && !empty($user->rights->query->dashboard->viewin)) {
            define('INC_FROM_DOLIBARR', true);
            dol_include_once('/query/config.php');
            dol_include_once('/query/class/dashboard.class.php');
            dol_include_once('/query/class/query.class.php');
            $PDOdb = new TPDOdb();
            $TDash = TQDashBoard::getDashboard($PDOdb, $parameters['currentcontext'], $user->id);
            foreach ($TDash as $uid) {
                $url = dol_buildpath('/query/dashboard.php?action=run&allow_gen=1&uid=' . $uid . '&table_element=' . $object->table_element . '&fk_object=' . $object->id, 1);
                ?>
				<tr>
					<td colspan="2">
						<iframe src="<?php 
                echo $url;
                ?>
" width="100%" frameborder="0" onload="this.height = this.contentWindow.document.body.scrollHeight + 'px'"></iframe>
					</td>
				</tr>
				<?php 
            }
        }
    }
function _get_company_object(&$TRender)
{
    global $db, $conf, $langs, $user;
    dol_include_once('/societe/class/societe.class.php');
    foreach ($TRender as $fk_soc => &$line) {
        $s = new Societe($db);
        $s->fetch($fk_soc);
        $line['client'] = $s->name;
    }
}
function grapefruitGetTasksForProject($name = 'fk_task', $socid = -1, $showempty = 1, $projectid = 0)
{
    global $db;
    dol_include_once('/core/class/html.form.class.php');
    $form = new Form($db);
    $TTask = getTaskByProjectId($projectid);
    $return = array();
    $return['value'] = $form->selectarray('fk_task', $TTask, '', 1, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth300', 1);
    echo json_encode($return);
}
Example #11
0
/**
 * Check validity of user/password/entity
 * If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
 *
 * @param	string	$usertotest		Login
 * @param	string	$passwordtotest	Password
 * @param   int		$entitytotest   Number of instance (always 1 if module multicompany not enabled)
 * @return	string					Login if OK, '' if KO
 */
function check_user_password_otp($usertotest, $passwordtotest, $entitytotest)
{
    global $db, $conf, $dolibarr_main_cookie_cryptkey;
    dol_include_once('/core/login/functions_dolibarr.php');
    //We first check if user & password are OK
    if (check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotest) == '') {
        return '';
    }
    // Force master entity in transversal mode
    $entity = $entitytotest;
    if (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode)) {
        $entity = 1;
    }
    $sql = 'SELECT rowid, otp_seed, otp_counter';
    $sql .= ' FROM ' . MAIN_DB_PREFIX . "user";
    $sql .= ' WHERE login = "******"';
    $sql .= ' AND entity IN (0,' . ($entity ? $entity : 1) . ")";
    dol_syslog("functions_dolibarr::check_user_password_dolibarr sql=" . $sql);
    $resql = $db->query($sql);
    if ($resql) {
        $obj = $db->fetch_object($resql);
        if ($obj) {
            //The user has not configured an OTP key
            if (!$obj->otp_seed) {
                return $usertotest;
            }
            //Now we validate OTP
            $providedOTP = GETPOST('otp');
            if (empty($providedOTP)) {
                return '';
            }
            /**
             * Examples from http://es.php.net/mcrypt_encrypt
             */
            $ciphertext_dec = base64_decode($obj->otp_seed);
            $key = pack('H*', $dolibarr_main_cookie_cryptkey);
            # recupera la IV, iv_size debería crearse usando mcrypt_get_iv_size()
            $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
            $iv_dec = substr($ciphertext_dec, 0, $iv_size);
            # recupera el texto cifrado (todo excepto el $iv_size en el frente)
            $ciphertext_dec = substr($ciphertext_dec, $iv_size);
            # podrían eliminarse los caracteres con valor 00h del final del texto puro
            $otpSeed = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec);
            $otplib = new \Rych\OTP\HOTP($otpSeed);
            if ($otplib->validate($providedOTP, $obj->otp_counter)) {
                $obj->otp_counter++;
                $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET otp_counter = '" . $obj->otp_counter . "' WHERE rowid = " . $obj->rowid;
                $db->query($sql);
                // Now the user is authenticated
                return $usertotest;
            }
        }
    }
    return '';
}
 static function setVersion(&$DoliDb, $moduleName)
 {
     if (class_exists($moduleName)) {
         dol_include_once('/core/lib/admin.lib.php');
         $mod = new $moduleName($DoliDb);
         if (!empty($mod->version)) {
             $version = $mod->version;
             dolibarr_set_const($DoliDb, 'ATM_MODULE_VERSION_' . strtoupper($moduleName), $version);
         }
     }
 }
 /**
  * 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
  */
 function doActions($parameters, &$object, &$action, $hookmanager)
 {
     //var_dump($parameters, $action);
     if (!empty($parameters['currentcontext'])) {
         $currentcontext = $parameters['currentcontext'];
     } else {
         $currentcontext = $parameters['context'];
     }
     // Retrocompatibility <= 3.6
     $routeAction = $currentcontext . ':' . $action;
     define('INC_FROM_DOLIBARR', true);
     dol_include_once('/routing/config.php');
     TRouting::route($routeAction, $object);
 }
    /**
     * 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
     */
    function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
    {
        if (in_array('propalcard', explode(':', $parameters['context'])) || in_array('ordercard', explode(':', $parameters['context']))) {
            global $langs, $conf;
            $langs->load('free2product@free2product');
            global $addButtonToConvertAll;
            $base_new_ref = !empty($conf->global->FREE2PRODUCT_BASE_NEWREF) ? $conf->global->FREE2PRODUCT_BASE_NEWREF : 'FREELINE-';
            if ($addButtonToConvertAll) {
                // On ajoute l'inclusion d'abricot
                define('INC_FROM_DOLIBARR', true);
                dol_include_once('/free2product/config.php');
                ?>
				<div class="inline-block divButAction">
					<a class="butAction" href="javascript:convertAllFreeLine();">
						<?php 
                echo $langs->trans('convertAllFreeLine');
                ?>
					</a>
					
				</div>

				<div id="convertAllFreeLine_popup" style="display:none">
					<?php 
                $formCore = new TFormCore();
                ?>
					<table class="border" width="100%">
						<?php 
                foreach ($object->lines as &$line) {
                    if ($line->product_type <= 1 && $line->fk_product == 0) {
                        $lineid = !empty($line->id) ? $line->id : $line->rowid;
                        // compatibilité 3.6
                        $desc = !empty($line->desc) ? $line->desc : $line->description;
                        // compatibilité 3.6
                        echo '<tr>
										<td>' . $formCore->texte('', 'TFreeProduct[' . $line->id . '][ref]', $base_new_ref . $lineid, 15, 255, ' lineid="' . $lineid . '" label="' . htmlentities(addslashes($desc)) . '" qty="' . $line->qty . '" price="' . $line->subprice . '" product_type="' . $line->product_type . '" tva="' . $line->tva_tx . '" ') . '</td>
										<td>' . $line->desc . '</td>
										<td align="right">' . price($line->subprice) . '</td>
										<td align="right">' . price($line->qty) . '</td>
									</tr>';
                    }
                }
                ?>
					</table>
					
				</div>
					<?php 
            }
        }
    }
 static function addEvent($fk_facture, $ref = '')
 {
     global $db, $langs, $user;
     dol_include_once('/comm/action/class/actioncomm.class.php');
     $a = new ActionComm($db);
     $a->type_code = 'AC_OTH_AUTO';
     $a->label = $langs->trans('BillClassifyDeposed', $ref);
     $a->fk_element = $fk_facture;
     $a->elementtype = 'facture';
     $a->usertodo = $user;
     $a->userdone = $user;
     $a->percentage = 100;
     $a->datep = date('Y-m-d H:i:s');
     $a->add($user);
 }
 static function getAllUser(&$PDOdb, &$db, &$conf)
 {
     if (!class_exists('User')) {
         dol_include_once('/user/class/user.class.php');
     }
     $TRes = array();
     $TUserId = $PDOdb->ExecuteAsArray('SELECT rowid FROM ' . MAIN_DB_PREFIX . 'user WHERE statut = 1');
     foreach ($TUserId as $obj) {
         $user = new User($db);
         $user->fetch($obj->rowid);
         $user->getrights();
         $TRes[] = array('user' => $user, 'dolidacticiel' => TDolidacticiel::getAll($PDOdb, $user, $conf));
     }
     return $TRes;
 }
 /**
  * Function called when a Dolibarrr business event is done.
  * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
  *
  * @param string		$action		Event action code
  * @param Object		$object     Object
  * @param User			$user       Object user
  * @param Translate		$langs      Object langs
  * @param conf			$conf       Object conf
  * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
  */
 public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
 {
     // Mettre ici le code a executer en reaction de l'action
     // Les donnees de l'action sont stockees dans $object
     if ($action == 'PAYPAL_PAYMENT_OK') {
         dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". source=" . $object->source . " ref=" . $object->ref);
         if (!empty($object->source)) {
             if ($object->source == 'membersubscription') {
                 //require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php';
                 // TODO add subscription treatment
             } else {
                 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
                 $soc = new Societe($this->db);
                 // Parse element/subelement (ex: project_task)
                 $element = $path = $filename = $object->source;
                 if (preg_match('/^([^_]+)_([^_]+)/i', $object->source, $regs)) {
                     $element = $path = $regs[1];
                     $filename = $regs[2];
                 }
                 // For compatibility
                 if ($element == 'order') {
                     $path = $filename = 'commande';
                 }
                 if ($element == 'invoice') {
                     $path = 'compta/facture';
                     $filename = 'facture';
                 }
                 dol_include_once('/' . $path . '/class/' . $filename . '.class.php');
                 $classname = ucfirst($filename);
                 $obj = new $classname($this->db);
                 $ret = $obj->fetch('', $object->ref);
                 if ($ret < 0) {
                     return -1;
                 }
                 // Add payer id
                 $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
                 // Add transaction id
                 $obj->setValueFrom('ref_int', $object->resArray["TRANSACTIONID"]);
             }
         } else {
             // TODO add free tag treatment
         }
     }
     return 0;
 }
Example #18
0
 /**
  * Constructor
  *
  * @param array		$options		Options array
  * @param int		$fk_element		fk_element
  * @param string	$element		element
  */
 function __construct($options = null, $fk_element = null, $element = null)
 {
     global $db, $conf;
     global $object;
     $this->fk_element = $fk_element;
     $this->element = $element;
     $pathname = $filename = $element;
     if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) {
         $pathname = $regs[1];
         $filename = $regs[2];
     }
     // For compatibility
     if ($element == 'propal') {
         $pathname = 'comm/propal';
         $dir_output = $conf->{$element}->dir_output;
     } elseif ($element == 'facture') {
         $pathname = 'compta/facture';
         $dir_output = $conf->{$element}->dir_output;
     } elseif ($element == 'project') {
         $element = $pathname = 'projet';
         $dir_output = $conf->{$element}->dir_output;
     } elseif ($element == 'fichinter') {
         $element = 'ficheinter';
         $dir_output = $conf->{$element}->dir_output;
     } elseif ($element == 'order_supplier') {
         $pathname = 'fourn';
         $filename = 'fournisseur.commande';
         $dir_output = $conf->fournisseur->commande->dir_output;
     } else {
         $dir_output = $conf->{$element}->dir_output;
     }
     dol_include_once('/' . $pathname . '/class/' . $filename . '.class.php');
     $classname = ucfirst($filename);
     if ($element == 'order_supplier') {
         $classname = 'CommandeFournisseur';
     }
     $object = new $classname($db);
     $object->fetch($fk_element);
     $object->fetch_thirdparty();
     $this->options = array('script_url' => $_SERVER['PHP_SELF'], 'upload_dir' => $dir_output . '/' . $object->ref . '/', 'upload_url' => DOL_URL_ROOT . '/document.php?modulepart=' . $element . '&attachment=1&file=/' . $object->ref . '/', 'param_name' => 'files', 'delete_type' => 'DELETE', 'max_file_size' => null, 'min_file_size' => 1, 'accept_file_types' => '/.+$/i', 'max_number_of_files' => null, 'max_width' => null, 'max_height' => null, 'min_width' => 1, 'min_height' => 1, 'discard_aborted_uploads' => true, 'image_versions' => array('thumbnail' => array('upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/', 'upload_url' => DOL_URL_ROOT . '/document.php?modulepart=' . $element . '&attachment=1&file=/' . $object->ref . '/thumbs/', 'max_width' => 80, 'max_height' => 80)));
     if ($options) {
         $this->options = array_replace_recursive($this->options, $options);
     }
 }
function _priceUpdateDolibarr(&$db, &$conf, &$langs)
{
    dol_include_once('/product/class/product.class.php');
    $error = 0;
    $fk_category = GETPOST('fk_category', 'int');
    $tms = dol_mktime(GETPOST('tmshour', 'int'), GETPOST('tmsmin', 'int'), 0, GETPOST('tmsmonth', 'int'), GETPOST('tmsday', 'int'), GETPOST('tmsyear', 'int'));
    $percentage = (double) GETPOST('percentage');
    if ($fk_category <= -1) {
        setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('quickpriceupdate_category_required')), null, 'errors');
        $error++;
    }
    if ($tms == '') {
        setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('quickpriceupdate_date_required')), null, 'errors');
        $error++;
    }
    if (!$error && $percentage != 0) {
        $tms = date('Y-m-d H:i:00', $tms);
        _priceUpdateDolibarrAction($db, $conf, $langs, $fk_category, $tms, $percentage);
    }
}
function _autocomplete_lot_number(&$PDOdb, $productid)
{
    global $db, $conf, $langs;
    $langs->load('other');
    dol_include_once('/core/lib/product.lib.php');
    $sql = "SELECT DISTINCT(lot_number),rowid, SUM(contenancereel_value) as qty, contenancereel_units as unit\n\t\t\tFROM " . MAIN_DB_PREFIX . "asset\n\t\t\tWHERE fk_product = " . $productid . " GROUP BY lot_number,contenancereel_units,rowid";
    $PDOdb->Execute($sql);
    $TLotNumber = array('');
    $PDOdb->Execute($sql);
    $Tres = $PDOdb->Get_All();
    foreach ($Tres as $res) {
        $asset = new TAsset();
        $asset->load($PDOdb, $res->rowid);
        $asset->load_asset_type($PDOdb);
        //pre($asset,true);exit;
        $TLotNumber[$res->lot_number]['lot_number'] = $res->lot_number;
        $TLotNumber[$res->lot_number]['label'] = $res->lot_number . " / " . $res->qty . " " . ($asset->assetType->measuring_units == 'unit' ? 'unité(s)' : measuring_units_string($res->unit, $asset->assetType->measuring_units));
    }
    return $TLotNumber;
}
 /**
  * 	Enter description here ...
  *
  * 	@param	string	$action		Action type
  */
 function getLoginPageOptions($parameters, &$object, &$action = '', $hook)
 {
     global $conf, $user, $langs;
     $langs->load("pos@pos");
     if (strstr($_SERVER["REQUEST_URI"], 'pos/frontend/index')) {
         $this->getInstanceDao();
         dol_include_once('/pos/class/mobile_detect.php');
         dol_include_once('/pos/class/pos.class.php');
         $terminals = POS::select_Terminals();
         if (sizeof($terminals)) {
             $result = '<select class="flat" id="terminal" name="terminal">' . "\n";
             $detect = new Mobile_Detect();
             $i = 0;
             foreach ($terminals as $terminal) {
                 if ($detect->isMobile()) {
                     if ($terminal["tactil"] == 2) {
                         $result .= "<option value='" . $terminal["rowid"] . "'>" . $terminal["name"] . "</option>\n";
                     }
                 } else {
                     $result .= "<option value='" . $terminal["rowid"] . "'>" . $terminal["name"] . "</option>\n";
                 }
                 $i++;
             }
             $result .= '</select>' . "\n";
         } else {
             $result .= '<label>' . $langs->trans("NotHasTerminal") . '</label>';
         }
         $divformat = '<div class="terminalBox"><strong><label for="Terminal">' . $langs->trans('Terminal') . '</label></strong>';
         $divformat .= $result;
         $divformat .= '</div>';
         $this->results['options']['div'] = $divformat;
         $tableformat = '<tr><td class="loginfield nowrap" valign="middle"><strong><label for="Terminal">' . $langs->trans('Terminal') . '</label></strong></td>';
         $tableformat .= '<td valign="top" nowrap="nowrap">';
         $tableformat .= $result;
         $tableformat .= '</td></tr>';
         $this->results['options']['table'] = $tableformat;
         return 1;
     }
 }
    /**
     * 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
     */
    function formObjectOptions($parameters, &$object, &$action, $hookmanager)
    {
        if (empty($object->element)) {
            return 0;
        }
        if (defined('TWIIITOR_ADDED')) {
            return 0;
        }
        define('TWIIITOR_ADDED', true);
        define('INC_FROM_DOLIBARR', true);
        dol_include_once('/twiiitor/config.php');
        dol_include_once('/twiiitor/class/twiiitor.class.php');
        $ref = TTwiiit::getRefByObject($object);
        if (empty($ref)) {
            return 0;
        }
        ?>
		<script type="text/javascript" src="<?php 
        echo dol_buildpath('/twiiitor/js/twiiitor.js.php?element=' . $object->element . '&id=' . $object->id . '&ref=' . $ref, 1);
        ?>
"></script>
		<?php 
    }
 function mouvement(&$PDOdb, &$object, $fk_product, $qty, $fk_warehouse_from, $fk_warehouse_to)
 {
     global $db, $user, $langs;
     dol_include_once('/product/stock/class/mouvementstock.class.php');
     dol_include_once('/product/class/product.class.php');
     /*var_dump($fk_product, $qty,$fk_warehouse_from, $fk_warehouse_to);
     		exit;
     			*/
     $stock = new MouvementStock($db);
     $label = '';
     if (method_exists($object, 'getNomUrl')) {
         $label .= $object->getNomUrl(1);
     }
     if (!empty($conf->global->ROUTING_INFO_ALERT)) {
         $product = new Product($db);
         $product->fetch($fk_product);
         $msg = $product->getNomUrl(0) . ' ' . $product->label . ' ' . $langs->trans('MoveFrom') . ' ' . $wh_from_label . ' ' . $langs->trans('MoveTo') . ' ' . $wh_to_label;
         setEventMessage($msg);
     }
     $stock->origin = $object;
     $stock->reception($user, $fk_product, $fk_warehouse_to, $qty, 0, $label);
     $stock->livraison($user, $fk_product, $fk_warehouse_from, $qty, 0, $label);
 }
 function createFacture(&$object, &$TLine)
 {
     global $user, $conf, $langs, $db;
     dol_include_once('/fourn/class/fournisseur.facture.class.php');
     $facture = new FactureFournisseur($db);
     $facture->origin = $object->element;
     $facture->origin_id = $object->id;
     $facture->ref = '';
     $facture->ref_supplier = '';
     //$facture->ref_supplier  = $object->ref_supplier;
     $facture->socid = $object->socid;
     $facture->libelle = $object->libelle;
     $object->date = time();
     $facture->note_public = $object->note_public;
     $facture->note_private = $object->note_private;
     $facture->cond_reglement_id = $object->cond_reglement_id;
     $facture->fk_account = $object->fk_account;
     $facture->fk_project = empty($object->fk_project) ? null : $object->fk_project;
     $facture->fk_incoterms = $object->fk_incoterms;
     $facture->location_incoterms = $object->location_incoterms;
     $facture->ref_supplier = time();
     $facture->date_echeance = $facture->calculate_date_lim_reglement();
     foreach ($TLine as &$row) {
         $line = $row->line;
         $line->qty = $row->qty;
         $line->id = 0;
         $facture->lines[] = $line;
     }
     $res = $facture->create($user);
     if ($res > 0) {
         header('location:' . dol_buildpath('/fourn/facture/card.php?action=editref_supplier&id=' . $res, 1));
         exit;
     } else {
         //var_dump($res, $facture);
         setEventMessage("ImpossibleToCreateInvoice", "errors");
     }
 }
 /** Overloading the doActions function : replacing the parent's function with the one below 
  *  @param      parameters  meta datas of the hook (context, etc...) 
  *  @param      object             the object you want to process (an invoice if you are in invoice module, a propale in propale's module, etc...) 
  *  @param      action             current action (if set). Generally create or edit or null 
  *  @return       void 
  */
 function beforePDFCreation($parameters, &$object, &$action, $hookmanager)
 {
     // pour implementation dans Dolibarr 3.7
     if (in_array('pdfgeneration', explode(':', $parameters['context']))) {
         define('INC_FROM_DOLIBARR', true);
         dol_include_once('/dispatch/config.php');
         dol_include_once('/asset/class/asset.class.php');
         dol_include_once('/dispatch/class/dispatchdetail.class.php');
         global $conf;
         if (isset($parameters['object']) && get_class($object) == 'Expedition') {
             $PDOdb = new TPDOdb();
             foreach ($object->lines as &$line) {
                 $sql = 'SELECT DISTINCT(lot_number),rowid FROM ' . MAIN_DB_PREFIX . 'expeditiondet_asset WHERE fk_expeditiondet = ' . $line->line_id;
                 $PDOdb->Execute($sql);
                 $TRes = $PDOdb->Get_All();
                 if (count($TRes) > 0) {
                     $line->desc .= "<br>Lot(s) expédié(s) : ";
                     foreach ($TRes as $res) {
                         $dispatchDetail = new TDispatchDetail();
                         $dispatchDetail->load($PDOdb, $res->rowid);
                         $asset = new TAsset();
                         $asset->load($PDOdb, $dispatchDetail->fk_asset);
                         $asset->load_asset_type($PDOdb);
                         $unite = $asset->assetType->measuring_units == 'unit' ? 'unité(s)' : measuring_units_string($dispatchDetail->weight_reel_unit, $asset->assetType->measuring_units);
                         $desc = "<br>- " . $res->lot_number . " x " . $dispatchDetail->weight_reel . " " . $unite;
                         if (empty($conf->global->DISPATCH_HIDE_DLUO_PDF)) {
                             $desc .= ' (DLUO : ' . $asset->get_date('dluo') . ')';
                         }
                         $line->desc .= $desc;
                     }
                 }
             }
         }
         //pre($object,true);exit;
     }
 }
 /**
  *	Init array this->hooks with instantiated action controlers.
  *  First, a hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS
  *  with value 'nameofcontext1:nameofcontext2:...' into $this->const of module descriptor file.
  *  This make conf->hooks_modules loaded with an entry ('modulename'=>array(nameofcontext1,nameofcontext2,...))
  *  When initHooks function is called, with initHooks(list_of_contexts), an array this->hooks is defined with instance of controler
  *  class found into file /mymodule/class/actions_mymodule.class.php (if module has declared the context as a managed context).
  *  Then when a hook is executeHook('aMethod'...) is called, the method aMethod found into class will be executed.
  *
  *	@param	array	$arraycontext	    Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ...
  *	@return	int							Always 1
  */
 function initHooks($arraycontext)
 {
     global $conf;
     // Test if there is hooks to manage
     if (!is_array($conf->modules_parts['hooks']) || empty($conf->modules_parts['hooks'])) {
         return;
     }
     // For backward compatibility
     if (!is_array($arraycontext)) {
         $arraycontext = array($arraycontext);
     }
     $this->contextarray = array_unique(array_merge($arraycontext, $this->contextarray));
     // All contexts are concatenated
     foreach ($conf->modules_parts['hooks'] as $module => $hooks) {
         if ($conf->{$module}->enabled) {
             foreach ($arraycontext as $context) {
                 if (is_array($hooks)) {
                     $arrayhooks = $hooks;
                 } else {
                     $arrayhooks = explode(':', $hooks);
                 }
                 // Old system (for backward compatibility)
                 if (in_array($context, $arrayhooks)) {
                     $path = '/' . $module . '/class/';
                     $actionfile = 'actions_' . $module . '.class.php';
                     $pathroot = '';
                     // Include actions class overwriting hooks
                     $resaction = dol_include_once($path . $actionfile);
                     if ($resaction) {
                         $controlclassname = 'Actions' . ucfirst($module);
                         $actionInstance = new $controlclassname($this->db);
                         $this->hooks[$context][$module] = $actionInstance;
                     }
                 }
             }
         }
     }
     return 1;
 }
 /**		Return next value
  *      @param      objsoc      Object third party
  *      @param      ticket		Object ticket
  *      @param      mode        'next' for next value or 'last' for last value
  *      @return     string      Value if OK, 0 if KO
  */
 function getNextValue($objsoc, $facsim, $mode = 'next')
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php";
     // Get Mask value
     $mask = '';
     if (is_object($facsim) && $facsim->type == 2) {
         $mask = $conf->global->FACSIM_MURO_MASK_CREDIT;
     } else {
         $mask = $conf->global->FACSIM_MURO_MASK;
     }
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $where = '';
     //ww para warehouse
     if (preg_match('/\\{(w+)\\}/i', $mask, $regWare)) {
         dol_include_once("/pos/class/cash.class.php");
         require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
         $terminal = new Cash($db);
         $terminal->fetch($facsim->fk_cash);
         $warehouse = new Entrepot($db);
         $warehouse->fetch($terminal->fk_warehouse);
         $maskware = $regWare[1];
         $maskware_value = substr($warehouse->libelle, 0, dol_strlen($regWare[1]));
         //get n first characters of warehouse ref where n is length in mask
         $maskware_value = str_pad($maskware_value, dol_strlen($regWare[1]), "#", STR_PAD_RIGHT);
         $maskware_maskbefore = '{' . $maskware . '}';
         $maskware_maskafter = $maskware_value;
         $mask = str_replace($maskware_maskbefore, $maskware_maskafter, $mask);
     }
     //kk para terminal
     if (preg_match('/\\{(k+)\\}/i', $mask, $regTerm)) {
         dol_include_once("/pos/class/cash.class.php");
         $terminal = new Cash($db);
         $terminal->fetch($facsim->fk_cash);
         $maskterm = $regTerm[1];
         $maskterm_value = substr($terminal->ref, 0, dol_strlen($regTerm[1]));
         //get n first characters of warehouse ref where n is length in mask
         $maskterm_value = str_pad($maskterm_value, dol_strlen($regTerm[1]), "#", STR_PAD_RIGHT);
         $maskterm_maskbefore = '{' . $maskterm . '}';
         $maskterm_maskafter = $maskterm_value;
         $mask = str_replace($maskterm_maskbefore, $maskterm_maskafter, $mask);
     }
     $numFinal = get_next_value($db, $mask, 'facture', 'facnumber', $where, $objsoc, time(), $mode);
     if (!preg_match('/([0-9])+/', $numFinal)) {
         $this->error = $numFinal;
     }
     return $numFinal;
 }
Example #28
0
 /**
  * Return HTML string to put an output field into a page
  *
  * @param   string	$key            Key of attribute
  * @param   string	$value          Value to show
  * @param	string	$moreparam		To add more parametes on html input tag (only checkbox use html input for output rendering)
  * @return	string					Formated value
  */
 function showOutputField($key, $value, $moreparam = '')
 {
     global $conf, $langs;
     $label = $this->attribute_label[$key];
     $type = $this->attribute_type[$key];
     $size = $this->attribute_size[$key];
     $elementtype = $this->attribute_elementtype[$key];
     $unique = $this->attribute_unique[$key];
     $required = $this->attribute_required[$key];
     $params = $this->attribute_param[$key];
     $perms = $this->attribute_perms[$key];
     $list = $this->attribute_list[$key];
     $showsize = 0;
     if ($type == 'date') {
         $showsize = 10;
         $value = dol_print_date($value, 'day');
     } elseif ($type == 'datetime') {
         $showsize = 19;
         $value = dol_print_date($value, 'dayhour');
     } elseif ($type == 'int') {
         $showsize = 10;
     } elseif ($type == 'double') {
         if (!empty($value)) {
             $value = price($value);
         }
     } elseif ($type == 'boolean') {
         $checked = '';
         if (!empty($value)) {
             $checked = ' checked ';
         }
         $value = '<input type="checkbox" ' . $checked . ' ' . ($moreparam ? $moreparam : '') . ' readonly disabled>';
     } elseif ($type == 'mail') {
         $value = dol_print_email($value);
     } elseif ($type == 'phone') {
         $value = dol_print_phone($value);
     } elseif ($type == 'price') {
         $value = price($value, 0, $langs, 0, 0, -1, $conf->currency);
     } elseif ($type == 'select') {
         $value = $params['options'][$value];
     } elseif ($type == 'sellist') {
         $param_list = array_keys($params['options']);
         $InfoFieldList = explode(":", $param_list[0]);
         $selectkey = "rowid";
         $keyList = 'rowid';
         if (count($InfoFieldList) >= 3) {
             $selectkey = $InfoFieldList[2];
             $keyList = $InfoFieldList[2] . ' as rowid';
         }
         $fields_label = explode('|', $InfoFieldList[1]);
         if (is_array($fields_label)) {
             $keyList .= ', ';
             $keyList .= implode(', ', $fields_label);
         }
         $sql = 'SELECT ' . $keyList;
         $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
         if (strpos($InfoFieldList[4], 'extra') !== false) {
             $sql .= ' as main';
         }
         $sql .= " WHERE " . $selectkey . "='" . $this->db->escape($value) . "'";
         //$sql.= ' AND entity = '.$conf->entity;
         dol_syslog(get_class($this) . ':showOutputField:$type=sellist', LOG_DEBUG);
         $resql = $this->db->query($sql);
         if ($resql) {
             $value = '';
             // value was used, so now we reste it to use it to build final output
             $obj = $this->db->fetch_object($resql);
             // Several field into label (eq table:code|libelle:rowid)
             $fields_label = explode('|', $InfoFieldList[1]);
             if (is_array($fields_label) && count($fields_label) > 1) {
                 foreach ($fields_label as $field_toshow) {
                     $translabel = '';
                     if (!empty($obj->{$field_toshow})) {
                         $translabel = $langs->trans($obj->{$field_toshow});
                     }
                     if ($translabel != $field_toshow) {
                         $value .= dol_trunc($translabel, 18) . ' ';
                     } else {
                         $value .= $obj->{$field_toshow} . ' ';
                     }
                 }
             } else {
                 $translabel = '';
                 if (!empty($obj->{$InfoFieldList}[1])) {
                     $translabel = $langs->trans($obj->{$InfoFieldList}[1]);
                 }
                 if ($translabel != $obj->{$InfoFieldList}[1]) {
                     $value = dol_trunc($translabel, 18);
                 } else {
                     $value = $obj->{$InfoFieldList}[1];
                 }
             }
         } else {
             dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
         }
     } elseif ($type == 'radio') {
         $value = $params['options'][$value];
     } elseif ($type == 'checkbox') {
         $value_arr = explode(',', $value);
         $value = '';
         if (is_array($value_arr)) {
             foreach ($value_arr as $keyval => $valueval) {
                 $value .= $params['options'][$valueval] . '<br>';
             }
         }
     } elseif ($type == 'chkbxlst') {
         $value_arr = explode(',', $value);
         $param_list = array_keys($params['options']);
         $InfoFieldList = explode(":", $param_list[0]);
         $selectkey = "rowid";
         $keyList = 'rowid';
         if (count($InfoFieldList) >= 3) {
             $selectkey = $InfoFieldList[2];
             $keyList = $InfoFieldList[2] . ' as rowid';
         }
         $fields_label = explode('|', $InfoFieldList[1]);
         if (is_array($fields_label)) {
             $keyList .= ', ';
             $keyList .= implode(', ', $fields_label);
         }
         $sql = 'SELECT ' . $keyList;
         $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
         if (strpos($InfoFieldList[4], 'extra') !== false) {
             $sql .= ' as main';
         }
         // $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
         // $sql.= ' AND entity = '.$conf->entity;
         dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst', LOG_DEBUG);
         $resql = $this->db->query($sql);
         if ($resql) {
             $value = '';
             // value was used, so now we reste it to use it to build final output
             while ($obj = $this->db->fetch_object($resql)) {
                 // Several field into label (eq table:code|libelle:rowid)
                 $fields_label = explode('|', $InfoFieldList[1]);
                 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
                     if (is_array($fields_label) && count($fields_label) > 1) {
                         foreach ($fields_label as $field_toshow) {
                             $translabel = '';
                             if (!empty($obj->{$field_toshow})) {
                                 $translabel = $langs->trans($obj->{$field_toshow});
                             }
                             if ($translabel != $field_toshow) {
                                 $value .= dol_trunc($translabel, 18) . '<BR>';
                             } else {
                                 $value .= $obj->{$field_toshow} . '<BR>';
                             }
                         }
                     } else {
                         $translabel = '';
                         if (!empty($obj->{$InfoFieldList}[1])) {
                             $translabel = $langs->trans($obj->{$InfoFieldList}[1]);
                         }
                         if ($translabel != $obj->{$InfoFieldList}[1]) {
                             $value .= dol_trunc($translabel, 18) . '<BR>';
                         } else {
                             $value .= $obj->{$InfoFieldList}[1] . '<BR>';
                         }
                     }
                 }
             }
         } else {
             dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
         }
     } elseif ($type == 'link') {
         $out = '';
         // only if something to display (perf)
         if ($value) {
             $param_list = array_keys($params['options']);
             // 0 : ObjectName
             // 1 : classPath
             $InfoFieldList = explode(":", $param_list[0]);
             dol_include_once($InfoFieldList[1]);
             if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) {
                 $object = new $InfoFieldList[0]($this->db);
                 $object->fetch($value);
                 $value = $object->getNomUrl(3);
             } else {
                 dol_syslog('Error bad setup of extrafield', LOG_WARNING);
                 $out .= 'Error bad setup of extrafield';
             }
         }
     } elseif ($type == 'text') {
         $value = dol_htmlentitiesbr($value);
     } else {
         $showsize = round($size);
         if ($showsize > 48) {
             $showsize = 48;
         }
     }
     //print $type.'-'.$size;
     $out = $value;
     return $out;
 }
 /**
  *		Function called when module is enabled.
  *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  *		It also creates data directories
  *
  *      @param      string	$options    Options when enabling module ('', 'noboxes')
  *      @return     int             	1 if OK, 0 if KO
  */
 function init($options = '')
 {
     $sql = array();
     define('INC_FROM_DOLIBARR', true);
     dol_include_once('/of/config.php');
     dol_include_once('/of/script/create-maj-base.php');
     $result = $this->_load_tables('/of/sql/');
     dol_include_once('/core/class/extrafields.class.php');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('fk_of', 'Ordre de Fabrication', 'sellist', 0, '', 'projet_task', 0, 0, '', serialize(array('options' => array('assetOf:numero:rowid' => null))));
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('fk_product', 'Produit à fabriquer', 'sellist', 0, '', 'projet_task', 0, 0, '', serialize(array('options' => array('product:label:rowid' => null))));
     return $this->_init($sql, $options);
 }
Example #30
0
            $modCodeClient = new $module;
            // We verified if the tag prefix is used
            if ($modCodeClient->code_auto)
            {
                $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
            }
            $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
            if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
            if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
            {
                $module = substr($module, 0, dol_strlen($module)-4);
            }
            $dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
            foreach ($dirsociete as $dirroot)
            {
                $res=dol_include_once($dirroot.$module.".php");
                if ($res) break;
            }
            $modCodeFournisseur = new $module;
            // On verifie si la balise prefix est utilisee
            if ($modCodeFournisseur->code_auto)
            {
                $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
            }

            if (! empty($_POST["nom"]))
            {
                // We overwrite with values if posted
                $object->name					= $_POST["nom"];
                $object->prefix_comm			= $_POST["prefix_comm"];
                $object->client					= $_POST["client"];