public static function create_client($client = array())
 {
     $possible_dups = SI_Post_Type::find_by_meta(SI_Client::POST_TYPE, array(self::FRESHBOOKS_ID => $client['client_id']));
     // Don't create a duplicate if this was already imported.
     if (!empty($possible_dups)) {
         do_action('si_error', 'Client imported already', $client['client_id']);
         return;
     }
     if (!self::import_archived_data() && $client['folder'] != 'active') {
         return;
     }
     // args to create new client
     $address = array('street' => isset($client['contact_street']) && !is_array($client['p_street1']) ? self::esc__($client['contact_street']) : '', 'city' => isset($client['p_city']) && !is_array($client['p_city']) ? self::esc__($client['p_city']) : '', 'zone' => isset($client['p_state']) && !is_array($client['p_state']) ? self::esc__($client['p_state']) : '', 'postal_code' => isset($client['p_code']) && !is_array($client['p_code']) ? self::esc__($client['p_code']) : '', 'country' => isset($client['p_country']) && !is_array($client['p_country']) ? self::esc__($client['p_country']) : '');
     $args = array('address' => $address, 'company_name' => isset($client['company_name']) && !is_array($client['company_name']) ? $client['company_name'] : '', 'website' => isset($client['website']) && !is_array($client['website']) ? $client['website'] : '', 'currency' => isset($client['currency_code']) && !is_array($client['currency_code']) ? $client['currency_code'] : '');
     if (isset($client['company_name']) && $args['company_name'] == '') {
         if (is_array($client['first_name']) || is_array($client['last_name'])) {
             do_action('si_error', 'Client creation error', $client['client_id']);
             return;
         }
         $args['company_name'] = $client['first_name'] . ' ' . $client['last_name'];
     }
     $client_id = SI_Client::new_client($args);
     // notes
     if (isset($client['notes']) && $client['notes'] != '') {
         SI_Internal_Records::new_record($client['notes'], SI_Controller::PRIVATE_NOTES_TYPE, $client_id, '', 0);
     }
     // create import record
     update_post_meta($client_id, self::FRESHBOOKS_ID, $client['client_id']);
     return $client_id;
 }
Example #2
0
 public static function create_client($client = array())
 {
     // args to create new client
     $address = array('street' => $client['Address'] . ' ' . $client['Address 2'], 'city' => $client['City'], 'zone' => $client['State'], 'postal_code' => $client['Zip'], 'country' => $client['Country']);
     $args = array('address' => $address, 'company_name' => isset($client['Company']) ? $client['Company'] : $client['First Name'] . ' ' . $client['Last Name'], 'company_name' => isset($client['Company']) ? $client['Company'] : '', 'website' => isset($client['Web Address']) ? $client['Web Address'] : '', 'phone' => isset($client['Telephone']) ? $client['Telephone'] : '');
     $client_id = SI_Client::new_client($args);
     // notes
     if (isset($client['Notes']) && $client['Notes'] != '') {
         SI_Internal_Records::new_record($client['Notes'], SI_Controller::PRIVATE_NOTES_TYPE, $client_id, '', 0);
     }
     return $client_id;
 }
 public static function maybe_create_private_note()
 {
     if (!isset($_REQUEST['private_note_nonce'])) {
         self::ajax_fail('Forget something?');
     }
     $nonce = $_REQUEST['private_note_nonce'];
     if (!wp_verify_nonce($nonce, SI_Internal_Records::NONCE)) {
         self::ajax_fail('Not going to fall for it!');
     }
     if (!current_user_can('edit_sprout_invoices')) {
         return;
     }
     $record_id = SI_Internal_Records::new_record($_REQUEST['notes'], SI_Controller::PRIVATE_NOTES_TYPE, $_REQUEST['associated_id'], '', 0, false);
     $error = $record_id ? '' : si__('Private note failed to save, try again.');
     $data = array('id' => $record_id, 'content' => $_REQUEST['notes'], 'type' => si__('Private Note'), 'post_date' => si__('Just now'), 'error' => $error);
     header('Content-type: application/json');
     if (self::DEBUG) {
         header('Access-Control-Allow-Origin: *');
     }
     echo wp_json_encode($data);
     exit;
 }
 /**
  * Create a zap entry
  * @param  array $data 
  * @return int       
  */
 public function new_zap($data = array(), $event = '')
 {
     if (!isset($data->target_url)) {
         return;
     }
     if ($event == '') {
         if (isset($data->event)) {
             $event = $data->event;
         }
     }
     $id = SI_Internal_Records::new_record($data, self::RECORD, -1, $event);
     $zap = SI_Record::get_instance($id);
     $zap->set_excerpt($data->target_url);
     return $id;
 }
Example #5
0
 /**
  * Create a time entry
  * @param  array $args 
  * @return int       
  */
 public function new_time($data)
 {
     $id = SI_Internal_Records::new_record($data, self::TIME_RECORD, $this->get_id(), $data['note'], 0);
     return $id;
 }