public function copyRows($skipInvalidFormat = false) { $this->this_ci->db->select('*')->from($this->tableName); $rowsList = $this->this_ci->db->get()->result('array'); // get all data as array $this->rowsWorked = 0; $this->skipppedRowsCount = 0; $this->skipppedWithWrongFormatRowsCount = 0; foreach ($rowsList as $nextRow) { $updateRow = true; if ($skipInvalidFormat) { // skip strings in invalid format if (empty($nextRow[$this->columnName]) or !preg_match('/^\\d+$/', $nextRow[$this->columnName])) { $this->skipppedWithWrongFormatRowsCount++; $updateRow = false; continue; } } $newVal = apputils::ConvertUnStampToMysqlDateTime($nextRow[$this->columnName]); // get and convert value from string field if (empty($nextRow[$this->columnName])) { $this->skipppedRowsCount++; $updateRow = false; continue; } if ($updateRow) { $this->this_ci->db->where($this->keyColumnName, $nextRow[$this->keyColumnName]); // update temp field with datetime stamp $this->this_ci->db->update($this->tableName, array($this->temp_columnName => $newVal)); $this->rowsWorked++; } } }
function addnewuser() { if ($this->session->userdata('is_login') == TRUE) { if ($this->input->post('action') != "") { $action = $this->input->post('action'); if ($action == "add") { $firstname = $this->input->post('firstname'); $lastname = $this->input->post('lastname'); $email = $this->input->post('email'); $username = $this->input->post('username'); $password = $this->input->post('password'); $confirmpass = $this->input->post('con_pass'); $this->load->library('form_validation'); $this->form_validation->set_rules('firstname', 'First Name', 'trim|required|xss_clean'); $this->form_validation->set_rules('lastname', 'Last Name', 'trim|required|xss_clean'); $this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[5]|valid_email|xss_clean|callback_isEmailExist'); $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|xss_clean|callback_isUserNameExist'); $this->form_validation->set_rules('password', 'Password', 'trim|min_length[6]|max_length[40]|required|xss_clean|matches[con_pass]'); $this->form_validation->set_rules('con_pass', 'Confirm Password', 'trim|min_length[6]|max_length[40]|required|xss_clean'); if ($this->form_validation->run() == FALSE) { $returnmessage = array('message' => validation_errors(), 'status' => 0); echo json_encode($returnmessage); } else { // Set activation code to blank $activation_code = ""; // New admin user data $add_user = array('u_username' => $username, 'u_pass' => $this->users->encript($password), 'u_fname' => $firstname, 'u_lname' => $lastname, 'u_email' => $email, 'u_type' => 1, 'u_status' => 1, 'u_admin_approve' => 1, 'u_verify_code' => $activation_code, 'u_time' => apputils::ConvertUnStampToMysqlDateTime(time())); // Add new admin user and return ID $user_id = $this->users->add($add_user); // Prompt success $returnmessage = array('message' => "New Administrator Account Added.", 'status' => 1); echo json_encode($returnmessage); // Lanz Editted - June 17, 2013 // Administrator Activate Email Information $email_data['username'] = $username; $email_data['password'] = $password; $email_data['email_type'] = "Administrator Account Activate Email"; $email_content = $this->load->view('email/email-admin-activate', $email_data, true); // Buyer Activate Email Format $subject = "Oceantailer: Administrator Account Verification "; $from = "*****@*****.**"; $sender = "http://www.oceantailer.com"; $to = "" . $email; // Send email to new Buyer $this->send_message($email_content, $subject, $to, $from, $sender); } } } } }
function product_attachment() { $id = $this->input->post('product_id'); $file_name = $this->input->post('fname'); $time = time(); $image_upload_group_id = $this->inventories->get_image_upload_group_id($id); //$this->inventories->DebToFile('$image_upload_group_id::'.$image_upload_group_id, false); $image_link = 'product_image/' . $image_upload_group_id . '/' . $id . "/" . $file_name; //$this->inventories->DebToFile('$image_link::'.$image_link, false); $array_data = array("i_id" => $id, "ii_name" => $file_name, "ii_link" => $image_link, "ii_feat" => 0, "ii_time" => apputils::ConvertUnStampToMysqlDateTime($time)); $image_id = $this->inventories->add_image($array_data); //$this->inventories->DebToFile('$image_id::'.$image_id, false); $data_link['link'] = $image_link; $data_link['id'] = $image_id; $image_result = $this->load->view('admin/inventory/inventory-image-list', $data_link, true); echo $image_result; }
function add() { if ($this->session->userdata('is_login') == TRUE) { redirect('buyer', 'refresh'); } else { header('Access-Control-Allow-Origin: http://www.oceantailer.com'); if ($this->input->post('action') != "") { $action = $this->input->post('action'); if ($action == 'register') { // Basic Information $firstname = $this->input->post('firstname'); $lastname = $this->input->post('lastname'); $uname = $this->input->post('uname'); $email = $this->input->post('email'); $company = $this->input->post('company'); $permit = $this->input->post('permit'); $pass = $this->input->post('pass'); $conpass = $this->input->post('conpass'); // Credit Card Information /*$cctype = $this->input->post('cctype'); $ccuname = $this->input->post('ccuname'); $ccunum = $this->input->post('ccunum'); $ccuccv = $this->input->post('ccuccv'); $exp_month = $this->input->post('exp_month'); $exp_year = $this->input->post('exp_year'); */ // Billing Address Information $country = $this->input->post('country'); $add1 = $this->input->post('add1'); $add2 = $this->input->post('add2'); $city = $this->input->post('city'); $prov = $this->input->post('prov'); $postal = $this->input->post('postal'); $phone_num = $this->input->post('phone_num'); $phone_ext = $this->input->post('phone_ext'); // Additional Information $website = $this->input->post('website'); $how_you_find = $this->input->post('how_you_find'); $important = $this->input->post('important'); $avg_sales = $this->input->post('avg_sales'); // Load Form Validation Library $this->load->library('form_validation'); // Basic Information Validation $this->form_validation->set_rules('firstname', 'First Name', 'trim|required|xss_clean'); $this->form_validation->set_rules('lastname', 'Last Name', 'trim|required|xss_clean'); $this->form_validation->set_rules('uname', 'Username', 'trim|required|min_length[5]|xss_clean|callback_isUserNameExist'); $this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[5]|valid_email|xss_clean|callback_isEmailExist'); $this->form_validation->set_rules('pass', 'Password', 'trim|min_length[6]|max_length[40]|required|xss_clean|matches[conpass]'); $this->form_validation->set_rules('conpass', 'Confirm Password', 'trim|min_length[6]|max_length[40]|required|xss_clean'); $this->form_validation->set_rules('permit', 'FEID or State License Number', 'trim|required|xss_clean'); // Credit Card Validation /*$this->form_validation->set_rules('cctype','Credit Card','trim|required|xss_clean'); $this->form_validation->set_rules('ccuname','Credit Card Name','trim|required|xss_clean'); if($cctype == 3) // American Express $this->form_validation->set_rules('ccunum','Credit Card Number','trim|numeric|exact_length[15]|xss_clean'); else $this->form_validation->set_rules('ccunum','Credit Card Number','trim|numeric|exact_length[16]|xss_clean'); if($cctype == 3) // American Express $this->form_validation->set_rules('ccuccv','CCV Number','trim|numeric|exact_length[4]|xss_clean'); else $this->form_validation->set_rules('ccuccv','CCV Number','trim|numeric|exact_length[3]|xss_clean'); $this->form_validation->set_rules('exp_month','Expiration Month','trim|required|xss_clean'); $this->form_validation->set_rules('exp_year','Expiration Year','trim|required|xss_clean'); */ // Billing Address Validation $this->form_validation->set_rules('country', 'Country', 'trim|required|xss_clean'); $this->form_validation->set_rules('add1', 'Address 1', 'trim|required|xss_clean'); $this->form_validation->set_rules('add2', 'Address 2', 'trim|xss_clean'); $this->form_validation->set_rules('city', 'City', 'trim|required|xss_clean'); $this->form_validation->set_rules('prov', 'State/Province', 'trim|required|xss_clean'); $this->form_validation->set_rules('phone_num', 'Phone Number', 'trim|required|numeric|xss_clean'); $this->form_validation->set_rules('phone_ext', 'Phone Extension', 'trim|numeric|xss_clean'); // Additional Information Validation $this->form_validation->set_rules('website', 'Website', 'trim|xss_clean'); $this->form_validation->set_rules('how_you_find', 'How You Find Us', 'trim|xss_clean'); $this->form_validation->set_rules('important', 'Most Important From Suppliers', 'trim|xss_clean'); $this->form_validation->set_rules('avg_sales', 'Average Sales', 'trim|xss_clean'); // Run validation if ($this->form_validation->run() == FALSE) { $returnmessage = array('message' => "<div class='error-cont' style='color:red'>" . str_replace("\n", "<br>", validation_errors()) . "</div>", 'status' => 0); echo json_encode($returnmessage); } else { // Generate Activaton Code $activation_code = strtolower($this->rndm_strng('alnum', 25)); // New Buyer Information $add_user = array('u_username' => $uname, 'u_pass' => $this->users->encript($pass), 'u_fname' => $firstname, 'u_lname' => $lastname, 'u_company' => $company, 'u_permit' => $permit, 'u_email' => $email, 'u_type' => 3, 'u_status' => 0, 'u_admin_approve' => 0, 'u_verify_code' => $activation_code, 'u_pic' => "", 'u_time' => apputils::ConvertUnStampToMysqlDateTime(time())); // Add new buyer and return ID $user_id = $this->users->add($add_user); // New Buyer Credit Card Information /*$add_ccu = array( 'u_id' => $user_id, 'cc_id' => $cctype, 'ccu_name' => $ccuname, 'ccu_number' => $ccunum, 'ccu_ccv' => $ccuccv, 'ccu_exp_month' => $exp_month, 'ccu_exp_year' => $exp_year, 'ccu_isset' => 1 ); // Add new buyer credit card and return ID $ccu_id = $this->users->ccu_add($add_ccu); */ // New Buyer Billing Address $add_billing = array('u_id' => $user_id, 'c_id' => $country, 'ba_add1' => $add1, 'ba_add2' => $add2, 'ba_city' => $city, 'ba_province' => $prov, 'ba_postal' => $postal, 'ba_phone_num' => $phone_num, 'ba_phone_ext' => $phone_ext, 'ba_isset' => 1); $ba_id = $this->users->business_address_add($add_billing); // New Buyer Additional Information $add_more_info = array('u_id' => $user_id, 'website' => $website, 'how_you_find' => $how_you_find, 'important' => $important, 'avg_sales' => $avg_sales); $ba_id = $this->users->add_more_info($add_more_info); $returnmessage = array('message' => "<div class='success-cont' style='color: green'>" . "<p>Registration Success, Check Your Email for Confirmation</p>" . "</div>", 'status' => 1); echo json_encode($returnmessage); $email_data['user'] = $uname; $email_data['pasword'] = $pass; $email_data['activate'] = $activation_code; $email_data['email_type'] = "User Activate Account"; $email_content = $this->load->view('email/user-email', $email_data, true); $subject = "Oceantailer: Account Verification "; $from = "*****@*****.**"; $sender = "OceanTailer"; $to = $email; $this->send_message($email_content, $subject, $to, $from, $sender); /////////////add ticket system //////////////////////// /* $salt = $this->rndm_strng('alnum',64); $hash_password = $this->hash_password($pass,$salt); $add_user_ticket = array( 'name' => $firstname.' '.$lasttname, 'username' => $uname, 'password' => $hash_password, 'salt' => $salt, 'email' =>$company, 'authentication_id' =>1, 'group_id' => 0, 'user_level' => 1, 'allow_login' => 1, 'site_id' => 1, 'email_notifications' => 1, 'phone_number' => $phone_num.' '.$phone_ext, 'address' => $add1 ); $result = $this->users->add_to_ticket($add_user_ticket); /////////////add ticket system end //////////////////////// */ } } } else { // Redirect to Buyer Register Page redirect('buyer/register', 'refresh'); } } }
function enable_feedback($days) { $this->load->library('apputils'); /*fixed for issue#16*/ $time_allowed = strtotime("-" . strval($days) . " days"); $this->db->select('*'); $this->db->from('buyer_supplier_detail'); $this->db->join('supplier_shipprod_info', 'supplier_shipprod_info.bsd_id = buyer_supplier_detail.bsd_id', 'left'); $this->db->join('buyer_transaction', 'buyer_transaction.bt_id = buyer_supplier_detail.bt_id', 'left'); $this->db->where('bsd_status', 1); //Already Shipped; $this->db->where('bsd_is_feedback', 0); //Not Yet created Feedback //the ssi_time must be less than or equal to the time allowed set. $this->db->where("ssi_time <= '" . apputils::ConvertUnStampToMysqlDateTime($time_allowed) . "'"); // minus from current date to the date set for sending email, // and enable feedback features; $this->db->where('ssi_time <> ""'); //Already Shipped; $approved_orders = $this->db->get()->result(); foreach ($approved_orders as $order) { $started_date = strtotime($order->ssi_time); $added_date = strtotime("-" . $days . " days"); echo date('M d, Y H:i:s', $added_date) . ' ' . date('M d, Y H:i:s', $started_date); $data_update = array('bsd_is_feedback' => 1, 'bsd_buyer_rate' => 5); $this->suppliers->update_buyer_supplier_detail($data_update, 'bsd_id', $order->bsd_id); //enable feedback to the buyer $email_data['buyer_info'] = $this->info($order->u_buyer); $email_data['supplier_info'] = $this->info($order->u_supplier); $email_data['order_detail'] = $order; $email_data['email_type'] = "Notify Feedback"; $email_content = $this->load->view('email/user-email', $email_data, true); //echo $pass; // Buyer Activate Email Format $subject = "Give Us a Feedback from your Last Transaction (Oceantailer)"; $from = "*****@*****.**"; $sender = "http://www.oceantailer.com"; $to = "" . $email_data['buyer_info']->u_email; $this->send_message($email_content, $subject, $to, $from, $sender); } }
</p> </div> <div class="fl half clearfix"> <p class='p-infoformat fl'> <label class='label-infoformat fl'>Order Date: </label>  <?php echo $bt->bsd_timestamp; ?> </p> </div> <?php } ?> <div class="fl half clearfix"> <p class='p-infoformat fl'> <label class='label-infoformat fl'>Order Status: </label>   <?php echo apputils::orderStatus($bt->bsd_status); ?> <?php if ($bt->bsd_status == -1 || $bt->bsd_status == -4) { echo ": " . $bt->bsd_reason; } ?> </p> </div> </div> </div> <div class='right-inner clearfix'>
function refund() { if ($this->session->userdata('is_login') == TRUE) { $user_type = $this->session->userdata('type'); //get user type; $supplierId = $this->session->userdata('id'); //id of the loged in user if ($user_type == 2) { $bsd_id = $this->uri->segment(3); if ($this->input->post('action') != "") { $action = $this->input->post('action'); if ($action == 'save') { $prod_ref = $this->input->post('product_refund'); $ship_ref = $this->input->post('product_shipping'); $reason = $this->input->post('reason'); $memo = $this->input->post('memo'); $bsd = $this->input->post('bsd'); $refund_is_exist = $this->suppliers->check_refund_record($bsd_id); //if exist only update. else add a recorc $add_refund = array('orr_date' => apputils::ConvertUnStampToMysqlDateTime(time()), 'bsd_id' => $bsd, 'orr_prod_amnt' => $prod_ref, 'orr_ship_amnt' => $ship_ref, 'orr_total' => $prod_ref + $ship_ref, 'orr_memo' => $memo, 'orr_reason' => $reason); $array = array('bsd_reason' => "Order Refund", 'bsd_status' => -3); //-3 for refund order status $result = $this->suppliers->update_buyer_supplier_detail($array, 'bsd_id', $bsd); if ($refund_is_exist) { $result = $this->suppliers->update_refund_record($add_refund, 'bsd_id', $bsd); } else { $result = $this->suppliers->add_refund_record($add_refund); } } elseif ($action == 'delete') { } } else { $data['supplier'] = $this->suppliers->supplierinfo($supplierId); $data['refund_lists'] = $this->suppliers->list_refund(); $data['bt'] = $this->suppliers->shipping_list_grouped($supplierId, $bsd_id); $data['buyer'] = $this->buyers->buyerinfo($data['bt']->u_buyer); $data['btd'] = $this->suppliers->transaction_detail($supplierId, $bsd_id); if ($data['btd'] == false) { redirect('', 'refresh'); } else { $this->load->view('supplier/supplier-refund', $data); } } } } }
function confirm() { if ($this->session->userdata('is_login') == TRUE) { $user_type = $this->session->userdata('type'); //get user type; $user_id = $this->session->userdata('id'); if ($user_type == 2) { $action = $this->input->post('action'); if ($action == 'add') { $track = $this->input->post('track'); $bt_id = $this->input->post('bt_id'); $start = strtotime($this->input->post('start')); $bsd = $this->input->post('bsd'); $method = $this->input->post('method'); $carrier = $this->input->post('carrier'); $extra_cost = $this->input->post('extra_cost'); $shipped_info = $this->suppliers->shipping_list_grouped($user_id, $bsd); if ($shipped_info->bt_type) { switch ($shipped_info->bt_type) { case 'paypal': $payment_result = $this->direct_cc_payment($bt_id, $bsd, $extra_cost); break; case 'credit card': default: $payment_result = $this->authorizenet_cc_payment($bt_id, $bsd, $extra_cost); break; } } /*modifed for testing purposes by @redix, issue#16*/ if (1) { $data_insert = array('bsd_id' => $bsd, 'u_id' => $user_id, 'ssi_track' => $track, 'ssi_start' => $start, 'ssi_end' => '', 'ssi_shipMethod' => $method, 'ssi_carrier' => $carrier, 'ssi_shipExtra' => $extra_cost, 'ssi_time' => apputils::ConvertUnStampToMysqlDateTime(time()), 'ssi_status' => 1); $id = $this->suppliers->shipping_product_add_info($data_insert); $bsd_update = array('bsd_status' => '1', 'bsd_reason' => 'Shipped', 'bsd_trans_id' => $payment_result['trans_id'], 'bsd_timestamp' => strtotime($payment_result['time_stamp']), 'bsd_correlation_id' => $payment_result['cor_id'], 'bsd_ack' => $payment_result['ack']); $this->suppliers->update_buyer_supplier_detail($bsd_update, 'bsd_id', $bsd); $email_data['transaction'] = $this->suppliers->shipping_list_grouped($user_id, $bsd); $email_data['products'] = $this->suppliers->transaction_detail($user_id, $bsd); $email_data['user'] = $this->users->info($email_data['transaction']->buyer_u_id); $email_data['email_type'] = "Confirm Shipping Expense"; $email_content = $this->load->view('email/email-buyer-transaction', $email_data, true); $subject = "Oceantailer: Shipment Confirmation for Invoice #" . $email_data['transaction']->bt_invoice; $from = "*****@*****.**"; $sender = "OceanTrailer"; $to = "" . !empty($email_data['user']->u_additional_email) ? $email_data['user']->u_additional_email : $email_data['user']->u_email; $this->send_message($email_content, $subject, $to, $from, $sender); } echo json_encode($payment_result); } elseif ($action == 'request') { //$track = $this->input->post('track'); //$bt_id = $this->input->post('bt_id'); //$start = strtotime($this->input->post('start')); $bsd = $this->input->post('bsd'); //$method = $this->input->post('method'); //$id_carrier = $this->input->post('carrier'); $extra_cost = $this->input->post('extra_cost'); //$country = $this->input->post('country'); //$carrier = $this->suppliers->carrier_info($id_carrier); $data_insert = array('bsd_id' => $bsd, 'u_id' => $user_id, 'ssi_shipExtra' => $extra_cost, 'ssi_status' => 0); $ssi_id = $this->suppliers->shipping_product_add_info($data_insert); $bsd_update = array('bsd_status' => '-2', 'bsd_reason' => "Pending buyer's consent for new shipping fees"); $this->suppliers->update_buyer_supplier_detail($bsd_update, 'bsd_id', $bsd); $email_data['transaction'] = $this->suppliers->shipping_list_grouped($user_id, $bsd); $email_data['products'] = $this->suppliers->transaction_detail($user_id, $bsd); $email_data['user'] = $this->users->info($email_data['transaction']->buyer_u_id); $email_data['email_type'] = "Confirm Shipping Expense"; $email_content = $this->load->view('email/email-buyer-transaction', $email_data, true); //$email_content; $subject = "Oceantailer: Shipment Confirmation for Invoice #" . $email_data['transaction']->bt_invoice; $from = "*****@*****.**"; $sender = "OceanTrailer"; $to = "" . !empty($email_data['user']->u_additional_email) ? $email_data['user']->u_additional_email : $email_data['user']->u_email; //echo $email_content;exit; $this->send_message($email_content, $subject, $to, $from, $sender); $display = "<center><p>--Waiting for Cofirmation From the Buyer for the New Shipping Detail, Click <a href='#'>Here</a> to resend the Email--</p></center>"; $returnmessage = array('display' => $display, 'status' => 1); echo json_encode($returnmessage); } } } }
function update() { /*echo '<pre>$_POST::'.print_r($_POST,true).'</pre>'; echo '<pre>$_GET::'.print_r($_GET,true).'</pre>'; die("-1"); */ if ($this->session->userdata('is_login') == TRUE) { $user_type = $this->session->userdata('type'); //get user type; if ($this->input->post('action') != "") { $action = $this->input->post('action'); if ($action == 'update_product') { $i_id = $this->input->post('id'); $upc_ean = $this->input->post('upc_ean'); $manu_num = $this->input->post('manu_num'); $manu = $this->input->post('manu'); $brand = $this->input->post('brand'); $weight = $this->input->post('weight'); $weight_scale = $this->input->post('weight_scale'); //$item_price = $this->input->post('item_price'); $ship_alone = $this->input->post('ship_alone'); $height = $this->input->post('height'); $width = $this->input->post('width'); $depth = $this->input->post('depth'); $d_scale = $this->input->post('d_scale'); $category = $this->input->post('category'); $this->load->library('form_validation'); $this->form_validation->set_rules('upc_ean', 'UPC/EAN', 'trim|required|min_length[5]|numeric|xss_clean'); $this->form_validation->set_rules('manu_num', 'Manufacturing Number', 'trim|required|min_length[5]|xss_clean'); $this->form_validation->set_rules('manu', 'Manufacture', 'trim|required|xss_clean'); $this->form_validation->set_rules('brand', 'Brand', 'trim|required|xss_clean'); $this->form_validation->set_rules('weight', 'Weight', 'trim|required|xss_clean|numeric|greater_than[0]'); $this->form_validation->set_rules('weight_scale', 'Weight Scale', 'trim|required|xss_clean'); //$this->form_validation->set_rules('item_price','Item Price','trim|required|xss_clean|numeric'); $this->form_validation->set_rules('ship_alone', 'Ship Alone', 'trim|required|xss_clean'); /* $this->form_validation->set_rules('height','Height','trim|required|xss_clean'); $this->form_validation->set_rules('width','Width','trim|required|xss_clean'); $this->form_validation->set_rules('depth','Depth','trim|required|xss_clean'); */ if ($this->form_validation->run() == FALSE) { //If has invalid input $returnmessage = array('message' => validation_errors(), 'status' => 0); echo json_encode($returnmessage); } else { $array_update = array("upc_ean" => $upc_ean, "manuf_num" => $manu_num, "m_id" => $manu, "b_id" => $brand, "c_id" => $category, "weight" => $weight, "weightScale" => $weight_scale, "qty" => 0, "ship_alone" => $ship_alone, "d_height" => $height, "d_width" => $width, "d_dept" => $depth, "d_scale" => $d_scale, "i_time" => apputils::ConvertUnStampToMysqlDateTime(time())); $where = "i_id"; $result = $this->inventories->update($array_update, $i_id, $where); $returnmessage = array('message' => "Successfull Update", 'status' => 1); echo json_encode($returnmessage); } } elseif ($action == 'set_feature_image') { $id_sel = $this->input->post('imgid'); $product_id = $this->input->post('id'); $data_remove_set = array('ii_feat' => 0); $data_new_set = array('ii_feat' => 1); $this->inventories->update_featured_image($data_remove_set, $data_new_set, $id_sel, $product_id); } elseif ($action == 'update_stock') { $sku = $this->input->post('sku'); $quan = $this->input->post('quan'); $price = $this->input->post('price'); $ret_price = $this->input->post('ret_price'); $lead_time = $this->input->post('lead_time'); $min_order = $this->input->post('min_order'); $ic_id = $this->input->post('ic_id'); $ic_ship_cost = $this->input->post('ship_cost') != '' ? $this->input->post('ship_cost') : null; $ic_ship_country = $this->input->post('ship_from'); $ic_map = $this->input->post('map'); $ic_prom_text = $this->input->post('prom_text'); $case_pack = $this->input->post('case_pack'); $min_order = $this->input->post('min_order'); $this->load->library('form_validation'); $this->form_validation->set_rules('sku', 'SKU', 'trim|required|min_length[4]|xss_clean'); $this->form_validation->set_rules('quan', 'Quantity', 'trim|required|numeric|xss_clean|greater_than[-1]'); $this->form_validation->set_rules('price', 'Price', 'trim|required|numeric|xss_clean|greater_than[0]'); $this->form_validation->set_rules('ret_price', 'Retailed Price', 'trim|required|numeric|xss_clean|greater_than[0]'); $this->form_validation->set_rules('min_order', 'Minimum order', 'trim|required|numeric|xss_clean|greater_than[0]'); if ($ic_map != "") { $this->form_validation->set_rules('map', 'MAP', 'trim|numeric|xss_clean'); } $this->form_validation->set_rules('ship_cost', 'Ship Cost', 'trim|numeric|xss_clean'); $this->form_validation->set_rules('ship_from', 'Ship Country', 'trim|required|xss_clean'); $this->form_validation->set_rules('prom_text', 'Promo Text', 'trim|xss_clean'); $this->form_validation->set_rules('ic_id', 'Inventory Child ID', 'trim|required|xss_clean'); if ($this->form_validation->run() == FALSE) { $returnmessage = array('message' => validation_errors(), 'status' => 0); echo json_encode($returnmessage); } else { $update_array = array('SKU' => $sku, 'ic_quan' => $quan, 'ic_price' => $price, 'ic_retail_price' => $ret_price, 'ic_leadtime' => $lead_time, 'ic_ship_cost' => $ic_ship_cost, 'ic_ship_country' => $ic_ship_country, 'ic_map' => $ic_map, 'ic_prom_text' => $ic_prom_text, 'ic_case_pack' => $case_pack, 'ic_min_order' => $min_order, 'ic_time' => apputils::ConvertUnStampToMysqlDateTime(time())); $where = 'ic_id'; $this->inventories->update_stock($update_array, $where, $ic_id); $returnmessage = array('message' => "Success Update Child Inventory", 'status' => 1); echo json_encode($returnmessage); } } } else { $id_product = $this->uri->segment(3); if ($user_type == 1) { $data['product'] = $this->inventories->detail($id_product); $data['list_manufac'] = $this->manufacturers->listing(); $data['list_scale'] = $this->inventories->listing_scale(); $data['categories'] = $this->categories->listings("0"); $data['countries'] = $this->countries->listing_country(); $data['scale_dimension'] = $this->categories->scale_dimension_listing(); $data['default_country'] = $this->countries->default_country(); //select default country attribute $data['translation_list'] = $this->inventories->list_product_translation($id_product); $data['image_list'] = $this->inventories->list_image($id_product); if ($data['product'] == false) { redirect('', 'refresh'); } else { $this->load->view('admin/inventory/update-inventory', $data); } } elseif ($user_type == 2) { $data['product'] = $this->suppliers->detail_main_inventory($id_product); //id of the product if ($data['product']->master_uid == $this->session->userdata('id')) { $data['list_manufac'] = $this->manufacturers->listing(); $data['list_scale'] = $this->inventories->listing_scale(); $data['categories'] = $this->categories->listings("0"); $data['countries'] = $this->countries->listing_country(); $data['scale_dimension'] = $this->categories->scale_dimension_listing(); $data['default_country'] = $this->countries->default_country(); //select default country attribute $data['translation_list'] = $this->inventories->list_product_translation($data['product']->i_id); $data['image_list'] = $this->inventories->list_image($data['product']->i_id); if ($data['product'] == false) { redirect('', 'refresh'); } else { $this->load->view('supplier/supplier-update-inventory', $data); } } elseif ($data['product']->child_uid == $this->session->userdata('id')) { $data['categories'] = $this->categories->listings("0"); $data['inventory'] = $data['product']; $data['countries'] = $this->countries->listing_country(); $data['image_list'] = $this->inventories->list_image($data['product']->i_id); $this->load->view('supplier/supplier-update-inventory', $data); } else { redirect('', 'refresh'); } } } } else { redirect('', 'refresh'); } }
<div class="fl clearfix" rel="<?php echo $id; ?> "> <table style="border: 0px dotted;"> <?php if (!empty($ii_time) and $ii_time != '0000-00-00 00:00:00') { ?> <tr> <td> <?php echo apputils::ShowFormattedDateTime($ii_time, ''); ?> </td> </tr> <?php } ?> <tr> <td> <a onclick="return false" href="<?php echo base_url() . $link; ?> "> <button class='delete-image fl' onclick="return delete_image(<?php echo is_numeric($id) ? $id : "'{$id}'"; ?> );"></button> <button class='set-featured fr' onclick="return set_featured(<?php echo is_numeric($id) ? $id : "'{$id}'"; ?>
public function insertDB($val) { $this->load->model('brands'); $this->load->model('manufacturers'); $this->load->model('inventories'); $this->load->model('suppliers'); $val['Ship_Alone'] = $val['Ship_Alone'] == 'Y' || $val['Ship_Alone'] == 1 ? 1 : 0; $res = $this->db->delete('supplier_datafeeds', array('SKU' => $val['SKU'], 'user_id' => $this->session->userdata['id'])); $sqlinsert = array('user_id' => $this->session->userdata['id'], 'SKU' => $val['SKU'], 'Barcode' => $val['Barcode'], 'Manufacturer_Part_Number' => $val['Manufacturer_Part_Number'], 'Manufacturer_Name' => $val['Manufacturer_Name'], 'Brand_Name' => $val['Brand_Name'], 'Title' => $val['Title'], 'Description' => $val['Description'], 'Category_ID' => $val['Category_ID'], 'Ship_Alone' => $val['Ship_Alone'], 'Weight' => $val['Weight'], 'Height' => $val['Height'], 'Width' => $val['Width'], 'Depth' => $val['Depth'], 'LeadTime' => $val['LeadTime'], 'Quantity_In_Stock' => $val['Quantity_In_Stock'], 'StockPriceTier1' => $val['StockPriceTier1'], 'DropShip_Selling_Price' => $val['DropShip_Selling_Price'], 'MSRP' => trim($val['MSRP']) == '' || $val['MSRP'] == 0 ? $val['StockPriceTier1'] * 3 : $val['MSRP'], 'Promo_Text' => $val['Promo_Text'], 'MAP' => $val['MAP'], 'Shipping_Cost' => $val['Shipping_Cost'], 'ImageURL1' => $val['ImageURL1'], 'ImageURL2' => $val['ImageURL2'], 'ImageURL3' => $val['ImageURL3'], 'ImageURL4' => $val['ImageURL4'], 'ImageURL5' => $val['ImageURL5'], 'ImageURL6' => $val['ImageURL6'], 'Case_Pack' => $val['Case_Pack'] == "" ? 1 : $val['Case_Pack'], 'Min_Order' => $val['Min_Order'] == "" ? 1 : $val['Min_Order'], 'Material' => $val['Material'] == '' ? "" : $val['Material'], 'Color' => $val['Color'] == '' ? "" : $val['Color'], 'Team' => $val['Team'] == '' ? "" : $val['Team'], 'MinStockQTYTier1' => $val['MinStockQTYTier1'] == null || $val['MinStockQTYTier1'] == '' ? 1 : $val['MinStockQTYTier1']); $manufacturers = $this->manufacturers->listing($sqlinsert['Manufacturer_Name']); if (count($manufacturers) == 0) { $m_id = $this->manufacturers->add(array('m_name' => $sqlinsert['Manufacturer_Name'])); } else { $m_id = $manufacturers[0]->m_id; } $brands = $this->brands->listing("", $sqlinsert['Brand_Name']); if (count($brands) == 0) { $b_id = $this->brands->add(array('b_name' => $sqlinsert['Brand_Name'], 'm_id' => $m_id)); } else { $b_id = $brands[0]->b_id; } $this->db->like(array('SKU' => $sqlinsert['SKU'], 'u_id' => $this->session->userdata['id'])); $results = $this->db->get('inventory_child')->result(); $upd = false; if (count($results) > 0) { $upd = true; $i_id = $results[0]->i_id; $child = $results[0]->ic_id; } $product = array('u_id' => $this->session->userdata['id'], 'status' => 'active', 'upc_ean' => $sqlinsert['Barcode'], 'manuf_num' => $sqlinsert['Manufacturer_Part_Number'], 'm_id' => $m_id, 'b_id' => $b_id, 'c_id' => $sqlinsert['Category_ID'], 'weight' => $sqlinsert['Weight'], 'weightScale' => 'Pounds', 'qty' => 0, 'ship_alone' => $sqlinsert['Ship_Alone'], 'd_height' => $sqlinsert['Height'], 'd_width' => $sqlinsert['Width'], 'd_dept' => $sqlinsert['Depth'], 'd_scale' => 'Inches', 'i_time' => apputils::ConvertUnStampToMysqlDateTime(time()), 'material' => $sqlinsert['material'] == '' ? "" : $sqlinsert['material'], 'color' => $sqlinsert['color'] == '' ? "" : $sqlinsert['color'], 'team' => $sqlinsert['team'] == '' ? "" : $sqlinsert['team']); if ($upd) { $this->inventories->update($product, $i_id, 'i_id'); } else { $i_id = $this->inventories->add($product); } /** Delete all images */ $this->db->where('i_id', $i_id); $this->db->where('ii_src_url', NULL); $results = $this->db->get('inventory_image')->result(); foreach ($results as $result) { $path = base_dir() . 'product_image/' . $this->inventories->get_image_upload_group_id($result->i_id) . '/' . $result->i_id . '/' . $result->ii_name; if (file_exists($path)) { @unlink($path); } $this->db->where('ii_id', $result->ii_id); $this->db->delete('inventory_image'); } for ($i = 1; $i <= 6; $i++) { $img = trim($sqlinsert["ImageURL{$i}"]); $img = $this->suppliers->norm_url($img); if (!empty($img)) { $this->db->where('i_id', $i_id); $this->db->where('ii_src_url', $img); $i_results = $this->db->get('inventory_image')->result(); if (count($i_results) == 0) { $path = false; if (filter_var($img, FILTER_VALIDATE_URL)) { $path = $this->downloadImage($img, $i_id); } else { $path = base_dir() . $img; if (file_exists($path)) { $path = $this->copyToProduct($path, $i_id); } else { $path = false; } } if ($path != false) { $link = str_replace(base_dir(), '', $path); $image_id = $this->inventories->add_image(array("i_id" => $i_id, "ii_name" => basename($path), "ii_link" => $link, "ii_feat" => 0, "ii_src_url" => $img, "ii_time" => apputils::ConvertUnStampToMysqlDateTime(time()))); } } } } $translation = array('i_id' => $i_id, 'c_id' => 236, 'tr_title' => $sqlinsert['Title'], 'tr_short_desc' => '', 'tr_desc' => $sqlinsert['Description'], 'tr_time' => apputils::ConvertUnStampToMysqlDateTime(time())); if ($upd) { $this->db->where(array('i_id' => $i_id, 'c_id' => 236)); $res = $this->db->get('translation')->result(); if (count($res) > 0) { $tr_id = $res[0]->tr_id; $this->inventories->update_translation($translation, $tr_id); } else { $this->inventories->add_product_translation($translation); } } else { $this->inventories->add_product_translation($translation); } $stock = array('i_id' => $i_id, 'u_id' => $this->session->userdata['id'], 'SKU' => $sqlinsert['SKU'], 'ic_quan' => $sqlinsert['Quantity_In_Stock'], 'ic_price' => $sqlinsert['DropShip_Selling_Price'], 'ic_retail_price' => $sqlinsert['MSRP'], 'ic_leadtime' => $sqlinsert['LeadTime'], 'ic_map' => $sqlinsert['MAP'], 'ic_ship_cost' => $sqlinsert['Shipping_Cost'], 'ic_ship_country' => '236', 'ic_prom_text' => $sqlinsert['Promo_Text'], 'ic_time' => apputils::ConvertUnStampToMysqlDateTime(time()), 'ic_stockPriceTier1' => $sqlinsert['StockPriceTier1'], 'ic_minStockQTYTier1' => $sqlinsert['MinStockQTYTier1'] == null || $sqlinsert['MinStockQTYTier1'] == '' ? 1 : $sqlinsert['MinStockQTYTier1']); if ($upd) { $this->inventories->update_stock($stock, 'ic_id', $child); } else { $ic_id = $this->inventories->add_stock($stock); } $this->db->insert('supplier_datafeeds', $sqlinsert); return $upd; }