Ejemplo n.º 1
0
 /**
 	AccountJournalEntry save
 */
 function save()
 {
     if (strlen(trim($this->_data['note'])) == 0) {
         $this->_data['note'] = null;
     }
     return parent::save();
 }
Ejemplo n.º 2
0
 function save()
 {
     if (empty($this->_data['contact_id'])) {
         throw new \Exception('CE#20: Invalid Contact ID');
     }
     return parent::save();
 }
Ejemplo n.º 3
0
 /**
 	Invoice Model save()
 */
 function save()
 {
     if (empty($this->_data['auth_user_id'])) {
         $this->_data['auth_user_id'] = $_SESSION['uid'];
     }
     parent::save();
     $this->_updateBalance();
 }
Ejemplo n.º 4
0
 /**
 	Save
 */
 function save()
 {
     $this->note = utf8_decode($this->note);
     if (empty($this->_data['auth_user_id'])) {
         $this->_data['auth_user_id'] = $_SESSION['uid'];
     }
     $x = parent::save();
     $this->_updateBalance();
     return $x;
 }
Ejemplo n.º 5
0
 /**
 	Contact Model save()
 
 	Saves this contact object with some embedded logic
 */
 function save()
 {
     // $this->name = null;
     // if (!empty($this->first_name)) {
     //	 $this->name.= $this->first_name;
     // }
     // if (!empty($this->last_name)) {
     //	 $this->name.= ' ' . $this->last_name;
     // }
     // if (!empty($this->company)) {
     //	 $this->name.= (empty($this->name) ? null : '@') . $this->company;
     // }
     // Copy Data from Parent
     // if (!empty($this->company)) {
     //	 $p = new Contact($this->parent_id);
     //	 if (empty($this->phone)) {
     //		 $this->phone = $p->phone;
     //	 }
     //	 if (empty($this->url)) {
     //		 $this->url = $p->url;
     //	 }
     //	 if (empty($this->company)) {
     //		 $this->company = $p->company;
     //	 }
     // }
     // Normalise Name
     switch ($this->_data['kind']) {
         case 'Company':
         case 'Vendor':
             // if ( (!empty($this->company)) && (!empty($this->contact)) ) {
             //	 $this->name = sprintf('%s [%s]',$this->company,$this->contact);
             // } elseif (!empty($this->company)) {
             //	 $this->name = $this->company;
             // } else {
             //	 $this->name = $this->contact;
             // }
             $this->_data['name'] = trim($this->_data['company']);
             if (empty($this->_data['name'])) {
                 $this->_data['name'] = $this->_data['contact'];
             }
             break;
         case 'Person':
         default:
             if (!empty($this->_data['company']) && !empty($this->_data['contact'])) {
                 $this->_data['name'] = sprintf('%s [%s]', $this->_data['contact'], $this->_data['company']);
             } elseif (!empty($this->company)) {
                 $this->_data['name'] = $this->_data['company'];
             } else {
                 $this->_data['name'] = $this->_data['contact'];
             }
             break;
     }
     $this->_data['name'] = trim($this->_data['name']);
     $this->_data['email'] = strtolower($this->_data['email']);
     // $this->_data['sound_code'] = metaphone($this->_data['name']);
     $this->_data['url'] = Filter::uri($this->_data['url']);
     $this->_data['ats'] = date('Y-m-d H:i:s');
     $this->_data['cts'] = null;
     if (empty($this->_data['account_id'])) {
         $this->_data['account_id'] = null;
     }
     if (empty($this->_data['parent_id']) == 0) {
         $this->_data['parent_id'] = null;
     }
     $ret = parent::save();
     // Save Meta-Deta
     if (0 != count($this->_meta)) {
         $meta = $this->_meta;
         $this->_meta = array();
         foreach ($meta as $k => $v) {
             $this->setMeta($k, $v);
         }
     }
     return $ret;
 }