Beispiel #1
0
function loop($units)
{
    printf("Loop every %ss\n", SLEEP_SECONDS);
    $serial = getSerialConnection();
    while (true) {
        foreach ($units as &$unit) {
            $unit['actual'] = get_next_value($unit['actual'], $unit['range']);
            print "Sending {$unit['actual']} .. ";
            $value = chr($unit['actual']);
            $serial->sendMessage($value);
            print "OK\n";
            usleep(SLEEP_SECONDS * 1000000);
        }
    }
}
Beispiel #2
0
	/**		\brief      Renvoi prochaine valeur attribuee
	*      	\param      objsoc      Objet societe
	*      	\param      ficheinter	Object ficheinter
	*      	\return     string      Valeur
	*/
    function getNextValue($objsoc=0,$object='')
    {
		global $db,$conf;

		require_once(DOL_DOCUMENT_ROOT ."/lib/functions2.lib.php");

		// On d�fini critere recherche compteur
		$mask=$conf->global->FICHINTER_ARTIC_MASK;

		if (! $mask)
		{
			$this->error='NotConfigured';
			return 0;
		}

		$numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc->code_client,$object->date);

		return  $numFinal;
  }
 /**
  *  Return next value
  *
  *  @param	Societe		$objsoc     Object third party
  * 	@param	Propal		$propal		Object commercial proposal
  *  @return string      			Value if OK, 0 if KO
  */
 function getNextValue($objsoc, $propal)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     // On defini critere recherche compteur
     $mask = $conf->global->PROPALE_SAPHIR_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $date = $propal->datep;
     $customercode = $objsoc->code_client;
     $numFinal = get_next_value($db, $mask, 'propal', 'ref', '', $customercode, $date);
     return $numFinal;
 }
 /**
  *  Return next value
  *
  *  @param	Societe		$objsoc     	Object third party
  *  @param  Object		$object			Object delivery
  *  @return string      				Value if OK, 0 if KO
  */
 function getNextValue($objsoc, $object)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     // On defini critere recherche compteur
     $mask = $conf->global->LIVRAISON_SAPHIR_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $numFinal = get_next_value($db, $mask, 'livraison', 'ref', '', $objsoc->code_client, $object->date_livraison);
     return $numFinal;
 }
    /**		Return next value
     *      @param      objsoc      Object third party
     *      @param      facture		Object invoice
     *      @param      mode        'next' for next value or 'last' for last value
     *      @return     string      Value if OK, 0 if KO
     */
    function getNextValue($objsoc,$facture,$mode='next')
    {
        global $db,$conf;

        require_once(DOL_DOCUMENT_ROOT ."/lib/functions2.lib.php");

        // Get Mask value
        $mask = '';
        if (is_object($facture) && $facture->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
        else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
        if (! $mask)
        {
            $this->error='NotConfigured';
            return 0;
        }

        $where='';
        //if ($facture->type == 2) $where.= " AND type = 2";
        //else $where.=" AND type != 2";

        $numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc,$facture->date,$mode);
        if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal;

        return  $numFinal;
    }
 /**
  * Return next value
  *
  * @param	Societe		$objsoc     Object third party
  * @param  	Object	    $object		Object
  * @param	string		$mode       'next' for next value or 'last' for last value
  * @return 	string      			Value if OK, 0 if KO
  */
 function getNextValue($objsoc, $object, $mode = 'next')
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     // On defini critere recherche compteur
     $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc->code_fournisseur, $object->datef);
     return $numFinal;
 }
 /**
  * Return next value
  *
  * @param	Product		$objproduct     Object product
  * @param  	int		    $type       Produit ou service (0:product, 1:service)
  * @return 	string      			Value if OK, '' if module not configured, <0 if KO
  */
 function getNextValue($objproduct = 0, $type = -1)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     // Get Mask value
     $mask = '';
     if ($type == 0 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) {
         $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
     } else {
         if ($type == 1 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) {
             $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
         }
     }
     if (empty($mask)) {
         $this->error = 'NotConfigured';
         return '';
     }
     $field = '';
     $where = '';
     if ($type == 0) {
         $field = 'ref';
         //$where = ' AND client in (1,2)';
     } else {
         if ($type == 1) {
             $field = 'ref';
             //$where = ' AND fournisseur = 1';
         } else {
             return -1;
         }
     }
     $now = dol_now();
     $numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now);
     return $numFinal;
 }
 /**
  *	Return next value
  *
  *	@param	Societe		$objsoc     Third party object
  *	@param	Object		$shipment	Shipment object
  *	@return string      			Value if OK, 0 if KO
  */
 function getNextValue($objsoc, $shipment)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php";
     $mask = $conf->global->EXPEDITION_RIBERA_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc->code_client, $shipment->date_expedition);
     return $numFinal;
 }
 /**
  *  Return next value
  *
  *  @param	Societe		$objsoc		Object third party
  *  @param   Project		$project	Object project
  *  @return  string					Value if OK, 0 if KO
  */
 function getNextValue($objsoc, $project)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     // On defini critere recherche compteur
     $mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $date = empty($project->date_c) ? dol_now() : $project->date_c;
     $numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', $objsoc->code_client, $date);
     return $numFinal;
 }
Beispiel #10
0
 /**
  * 	Return next free value
  *
  *  @param	Societe		$objsoc     Object thirdparty
  *  @param  Object		$object		Object we need next value for
  *  @return string      			Value if KO, <0 if KO
  */
 function getNextValue($objsoc, $object)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     // We get cursor rule
     $mask = $conf->global->PAYMENT_ANT_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $numFinal = get_next_value($db, $mask, 'paiement', 'ref', '', $objsoc, $object->datepaye);
     return $numFinal;
 }
	/**		\brief      Return next value
	 *     	\param      objsoc      Object third party
	 *	    \param      $type       Client ou fournisseur (1:client, 2:fournisseur)
	 *     	\return     string      Value if OK, '' if module not configured, <0 if KO
	 */
	function getNextValue($objsoc=0,$type=-1)
	{
		global $db,$conf;

		require_once(DOL_DOCUMENT_ROOT ."/lib/functions2.lib.php");

		// Get Mask value
		$mask = '';
		if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
		if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
		if (! $mask)
		{
			$this->error='NotConfigured';
			return '';
		}

		$field='';$where='';
		if ($type == 0)
		{
			$field = 'code_client';
			//$where = ' AND client in (1,2)';
		}
		else if ($type == 1)
		{
			$field = 'code_fournisseur';
			//$where = ' AND fournisseur = 1';
		}
		else return -1;

		$now=gmmktime();

		$numFinal=get_next_value($db,$mask,'societe',$field,$where,'',$now);

		return  $numFinal;
	}
 /**
  *  Return next value
  *
  *  @param	Societe		$objsoc     Object third party
  *  @param  Object	    $object		Object
  *  @return string      			Value if OK, 0 if KO
  */
 function getNextValue($objsoc = 0, $object = '')
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php";
     // On defini critere recherche compteur
     $mask = $conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $numFinal = get_next_value($db, $mask, 'commande_fournisseur', 'ref', '', $objsoc->code_fournisseur, $object->date_commande);
     return $numFinal;
 }
 /**
  * 	Return next free value
  *
  *  @param	Societe		$objsoc     Object thirdparty
  *  @param  Object		$object		Object we need next value for
  *  @return string      			Value if KO, <0 if KO
  */
 function getNextValue($objsoc, $object)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php";
     // We get cursor rule
     $mask = $conf->global->COMMANDE_SAPHIR_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $numFinal = get_next_value($db, $mask, 'commande', 'ref', '', $objsoc->code_client, $object->date);
     return $numFinal;
 }
Beispiel #14
0
 /**
  * Return next value
  *
  * @param int $fk_user User creating
  * @param Societe $objsoc Party
  * @param Lead $lead Lead
  * @return string Valeur
  */
 function getNextValue($fk_user, $objsoc, $lead)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     // On defini critere recherche compteur
     $mask = $conf->global->LEAD_UNIVERSAL_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $numFinal = get_next_value($db, $mask, 'lead', 'ref', '', $objsoc->code_client, dol_now());
     return $numFinal;
 }
 /**
  * Return next value
  *
  * @param	Product		$objproduct     Object product
  * @param	string		$type       	type of barcode (EAN, ISBN, ...)
  * @return 	string      				Value if OK, '' if module not configured, <0 if KO
  */
 function getNextValue($objproduct, $type = '')
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     // TODO
     // Get Mask value
     $mask = '';
     if (!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) {
         $mask = $conf->global->BARCODE_STANDARD_PRODUCT_MASK;
     }
     if (empty($mask)) {
         $this->error = 'NotConfigured';
         return '';
     }
     $field = 'barcode';
     $where = '';
     $now = dol_now();
     $numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now);
     return $numFinal;
 }
 /**
  *	Return next value
  *
  *	@param	Societe		$objsoc     third party object
  *	@param	Object		$contract	contract object
  *	@return string      			Value if OK, 0 if KO
  */
 function getNextValue($objsoc, $contract)
 {
     global $db, $conf;
     require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php";
     $mask = $conf->global->CONTRACT_MAGRE_MASK;
     if (!$mask) {
         $this->error = 'NotConfigured';
         return 0;
     }
     $numFinal = get_next_value($db, $mask, 'contrat', 'ref', '', $objsoc->code_client, $contract->date_contrat);
     return $numFinal;
 }
 /**		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;
 }
 function getNumero(&$PDOdb, $save = false)
 {
     global $db;
     if (empty($this->numero)) {
         dol_include_once('core/lib/functions2.lib.php');
         $mask = 'OF{00000}';
         $numero = get_next_value($db, $mask, 'assetOf', 'numero');
         if ($save) {
             $this->numero = $numero;
             $wc = $this->withChild;
             $this->withChild = false;
             parent::save($PDOdb);
             $this->withChild = $wc;
         }
     } else {
         $numero = $this->numero;
     }
     return $numero;
 }