Пример #1
0
 /**
  *	Adding a line of intervention into data base
  *
  *  @param      user	$user					User that do the action
  *	@param    	int		$fichinterid			Id of intervention
  *	@param    	string	$desc					Line description
  *	@param      date	$date_intervention  	Intervention date
  *	@param      int		$duration            	Intervention duration
  *  @param		array	$array_option			Array option
  *	@return    	int             				>0 if ok, <0 if ko
  */
 function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_option = '')
 {
     dol_syslog(get_class($this) . "::addline {$fichinterid}, {$desc}, {$date_intervention}, {$duration}");
     if ($this->statut == 0) {
         $this->db->begin();
         // Insertion ligne
         $line = new FichinterLigne($this->db);
         $line->fk_fichinter = $fichinterid;
         $line->desc = $desc;
         $line->datei = $date_intervention;
         $line->duration = $duration;
         if (is_array($array_option) && count($array_option) > 0) {
             $line->array_options = $array_option;
         }
         $result = $line->insert($user);
         if ($result >= 0) {
             $this->db->commit();
             return 1;
         } else {
             $this->error = $this->db->error();
             $this->db->rollback();
             return -1;
         }
     }
 }
Пример #2
0
	/**
	 *	Adding a line of intervention into data base
	 *	@param    	fichinterid			Id of intervention
	 *	@param    	desc				Line description
	 *	@param      date_intervention  	Intervention date
	 *	@param      duration            Intervention duration
	 *	@return    	int             	>0 if ok, <0 if ko
	 */
	function addline($fichinterid, $desc, $date_intervention, $duration)
	{
		dol_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration");

		if ($this->statut == 0)
		{
			$this->db->begin();

			// Insertion ligne
			$line=new FichinterLigne($this->db);

			$line->fk_fichinter = $fichinterid;
			$line->desc         = $desc;
			$line->datei        = $date_intervention;
			$line->duration     = $duration;

			$result=$line->insert();
			if ($result > 0)
			{
				$this->db->commit();
				return 1;
			}
			else
			{
				$this->error=$this->db->error();
				dol_syslog("Error sql=$sql, error=".$this->error, LOG_ERR);
				$this->db->rollback();
				return -1;
			}
		}
	}