Esempio n. 1
0
 public function export()
 {
     if (!isset($_REQUEST['canvasData'])) {
         redirect("admin/tdesign/create");
     }
     $img = $_REQUEST['canvasData'];
     if (empty($img)) {
         $this->session->set_flashdata('error', lang("design:no_design_found"));
         redirect("admin/tdesign/create");
     }
     $img = str_replace('data:image/png;base64,', '', $img);
     $img = str_replace(' ', '+', $img);
     $data = base64_decode($img);
     $name = "temp" . uniqid() . '.png';
     $file = UPLOAD_PATH . '../design/templates/' . $name;
     $success = file_put_contents($file, $data);
     $this->load->library('product');
     $this->load->helper("tdesign");
     // create draft design
     $product = $this->product->create_draft(array("raw_url" => $file, "image" => get_design_image_path("templates", $name)));
     //redirect("admin/tdesign/create");
     if (empty($product)) {
         show_error("Service Currently Unvaiable");
         return;
     }
     redirect("admin/tdesign/form/" . $product->product_id . "/D");
 }
Esempio n. 2
0
 public function get($id)
 {
     if (!$this->allowViewAll()) {
         $this->db->where("user_id", $this->current_user->user_id);
     }
     /* if($row=$this->is_draft($id)){
     			return $row;
     		} */
     $subsql = "( select data from " . $this->dbprefix("tshirt_arts") . " where id=id_art ) as arts";
     $this->db->select(array("*", $subsql));
     $this->db->join($this->_descriptions, $this->_descriptions . '.product_id=' . $this->_table . '.product_id', "LEFT");
     $this->db->where('lang_code', CURRENT_LANGUAGE);
     $this->db->where('deleted', 0);
     $this->db->group_by("id_art");
     $result = $this->db->where($this->_table . '.product_id', $id)->get($this->_table)->row();
     $images = $this->get_images($id);
     if (!empty($images)) {
         $this->load->helper('tdesign');
         foreach ($images as $image) {
             $result->image[] = get_design_image_path("original", $image->id_image . '_' . $image->product_id . '.jpg');
         }
     }
     if (!empty($result->arts)) {
         $result->arts = unserialize($result->arts);
     }
     return $result;
 }
Esempio n. 3
0
 public function get_product($id)
 {
     //	$subsql="( select data from ".$this->dbprefix("tshirt_arts") ." where id=id_art ) as arts";
     $this->db->select(array("*", "list_price as price"));
     $this->db->join($this->_descriptions, $this->_descriptions . '.product_id=' . $this->_table . '.product_id', "LEFT");
     $this->db->where('lang_code', CURRENT_LANGUAGE);
     $this->db->where('deleted', 0);
     $this->db->group_by("id_art");
     $result = $this->db->where($this->_table . '.product_id', $id)->get($this->_table)->row();
     if (empty($result)) {
         return;
     }
     $images = $this->get_images($id);
     if (!empty($images)) {
         $this->load->helper('tdesign');
         foreach ($images as $image) {
             $result->image[] = get_design_image_path("original", $image->id_image . '_' . $image->product_id . '.jpg');
         }
     }
     // 		if(!empty($result->arts)){
     // 			$result->arts=unserialize($result->arts);
     // 		}
     return $result;
 }
Esempio n. 4
0
 public function export()
 {
     if (!isset($_REQUEST['base_64image'])) {
         $this->session->set_flashdata("error", lang("design:no_design_found"));
         redirect("admin/tdesign/create_design");
     }
     $base64_str = substr($_REQUEST['base_64image'], strpos($_REQUEST['base_64image'], ",") + 1);
     // decode base64 string
     $decoded = base64_decode($base64_str);
     // create png from decoded base 64 string and save the image in the parent folder
     $name = "temp" . uniqid() . '.png';
     $file = UPLOAD_PATH . '../design/designs/' . $name;
     $result = file_put_contents($file, $decoded);
     $this->load->library('product');
     $this->load->helper("tdesign");
     // create draft design
     $product = $this->product->create_draft(array("raw_url" => $file, "image" => get_design_image_path("templates", $name)));
     // redirect("admin/tdesign/create");
     if (empty($product)) {
         show_error("Service Currently Unvaiable");
         return;
     }
     $type = $this->input->post("product_type") ? $this->input->post("product_type") : "shirts";
     redirect("admin/tdesign/form/" . $product->product_id . "/" . $type);
 }