function submit_sale() { $saleId = (int) $this->input->post('saleId'); $price = $this->input->post('price'); //check that price is a good dollar amount if (!is_numeric($price)) { echo "-1"; return; } $desc = $this->input->post('desc'); $paypal = (bool) $this->input->post('paypal'); $money = (bool) $this->input->post('moneyorder'); $oi_id = (int) $this->input->post('oi_id'); $person_id = (int) $this->phpsession->get('personVO')->getPerson_id(); $mysqltime = date("Y-m-d H:i:s"); require_once APPPATH . 'models/VOs/SaleVO' . EXT; $saleVO = new SaleVO(); if ($saleId !== '') { $saleVO->setSaleId($saleId); $saleVO->Load(); } $saleVO->setPrice($price); $saleVO->setDescription($desc); $saleVO->setPaypal($paypal); $saleVO->setMoneyorder($money); $saleVO->setOwned_item_id($oi_id); $saleVO->setSellerId($person_id); $saleVO->setList_date($mysqltime); // if the seller submitted a custom picture if ($this->input->post('filename') != "stock" && $this->input->post('filename') != $saleVO->getCustomImg() && $this->input->post('filename') != 'custom') { $this->load->library('image_lib'); $config['image_library'] = 'gd2'; $config['source_image'] = './img/' . $this->phpsession->get('current_domain')->getTag() . '/uploads/' . $this->input->post('filename'); //initialize first to get the dimensions $this->image_lib->initialize($config); $config['width'] = "200"; $config['maintain_ratio'] = TRUE; //load width and ratio setting to resize image to 200px wide $this->image_lib->initialize($config); $this->image_lib->resize(); $this->image_lib->clear(); $config = array(); $config['image_library'] = 'gd2'; $config['quality'] = "25%"; $config['source_image'] = './img/' . $this->phpsession->get('current_domain')->getTag() . '/uploads/' . $this->input->post('filename'); $config['new_image'] = './img/' . $this->phpsession->get('current_domain')->getTag() . '/customs/' . $this->input->post('filename'); //begin configuration for cropping if ($this->input->post('x1') != "") { $config['x_axis'] = $this->input->post('x1'); $config['y_axis'] = $this->input->post('y1'); $config['width'] = $this->input->post('w'); $config['height'] = $this->input->post('h'); $config['maintain_ratio'] = FALSE; } else { $config['maintain_ratio'] = TRUE; } $this->image_lib->initialize($config); if (!$this->image_lib->crop()) { echo $this->image_lib->display_errors(); return; } else { //save custom image filename and delete original uploaded pic $saleVO->setCustomImg($this->input->post('filename')); //unlink('./img/'.$this->phpsession->get('current_domain')->getTag().'/uploads/'.$this->input->post('filename')); } } elseif ($this->input->post('filename') == 'custom') { $oiVO = $this->getOwnedItems(array($oi_id), false, false, true); $oiVO = current($oiVO); $saleVO->setCustomImg($oiVO->getCustImg()); } else { $saleVO->setCustomImg('stock'); } $ret = $saleVO->Save(); // if save was successful if ($ret > 0) { // Only send wish list notifications if this is a new listing, not an edit. if ($saleId == '') { $this->send_wishlist_emails($oi_id); } echo $saleVO->getSaleId(); } else { echo "-1"; } }