public function getImageWithBaseArticleID()
 {
     $id = addslashes($_GET['id']);
     $type = addslashes($_GET['type']);
     //if($id == "")die("no id");
     if ($id == "" || $id < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No ID";
         echo json_encode($json);
         die;
     }
     $ll = new LL_Article_WImage();
     $arr = $ll->getWhere("BaseArticleID = '{$id}' AND ArticleType = 'Base' LIMIT 0,1");
     $ll = $arr[0];
     if ($type != 1) {
         $type = 2;
     }
     if ($type == 1) {
         $dipil = "BaseArticleImageFile";
     } else {
         $dipil = "VariantImageFile";
     }
     //        $remoteImage = "http://192.168.0.86/ImageRepository/Article/Images/".$ll->$dipil;
     $remoteImage = Efiwebsetting::getData('ImageRepositoryURL') . $ll->{$dipil};
     $imginfo = getimagesize($remoteImage);
     header("Content-type: " . $imginfo['mime']);
     readfile($remoteImage);
     exit;
 }
 public function saveLocaly()
 {
     die('edit me');
     $prod = new LL_Article_WImage();
     $arr = $prod->getWhere("BaseArticleImageFile != ''");
     echo count($arr);
     $min = 500;
     $max = 800;
     $point = array(100, 200, 300, 400, 500, 600, 700);
     foreach ($arr as $num => $atr) {
         //            if($num<=$min)continue;
         //            if($num>=$max)break;
         if (!in_array($num, $point)) {
             continue;
         }
         //            pr($atr);
         $id = $atr->BaseArticleImageFile;
         $remoteImage = "http://43.231.128.129/LLProdImage/getImageJPG/" . $id;
         $img = _PHOTOPATH . "products/" . $id;
         echo $num . " . " . $img . "<br>";
         //            $ch = curl_init($remoteImage);
         //            $fp = fopen($img, 'wb');
         //            curl_setopt($ch, CURLOPT_FILE, $fp);
         //            curl_setopt($ch, CURLOPT_HEADER, 0);
         //            curl_exec($ch);
         //            curl_close($ch);
         //            fclose($fp);
         if (file_put_contents($img, file_get_contents($remoteImage))) {
             echo $num . " . " . $id . "<br>";
         }
         //            break;
     }
 }
 public function get()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $json['status_code'] = 1;
     $macc_id = addslashes($_GET['macc_id']);
     if (!$macc_id) {
         $json['status_code'] = 0;
         $json['status_message'] = "No ID Found";
         echo json_encode($json);
         die;
     }
     $llTesti = new LL_Wishlist();
     $arrW = $llTesti->getWhereFromMultipleTable("wl_acc_id = '{$macc_id}' AND wl_articlenr = VariantID ORDER BY VariantNameINA ASC", array("LL_Article_WImage"));
     //pr($arrW);
     $llacc = new LL_Article_WImage();
     //$llacc->VariantID
     $exp2 = explode(",", $llacc->crud_webservice_allowed);
     $arrPicsToAddPhotoUrl2 = $llacc->crud_add_photourl;
     $obj = $llTesti;
     $obj->default_read_coloms = $obj->crud_webservice_allowed;
     $main_id = $obj->main_id;
     $exp = explode(",", $obj->crud_webservice_allowed);
     $arrPicsToAddPhotoUrl = $obj->crud_add_photourl;
     $json = array();
     $json['status_code'] = 1;
     //$json['results_number'] = $obj->getJumlah($query);
     //
     $sudah = array();
     //filter
     foreach ($arrW as $o) {
         if (in_array($o->VariantID, $sudah)) {
             continue;
         }
         $sudah[] = $o->VariantID;
         $sem = array();
         foreach ($exp as $attr) {
             if (in_array($attr, $arrPicsToAddPhotoUrl)) {
                 $sem[$attr] = _PHOTOURL . $o->{$attr};
             } else {
                 $sem[$attr] = $o->{$attr};
             }
         }
         foreach ($exp2 as $attr) {
             //if($attr == "macc_ll_customer_id")break;
             if (in_array($attr, $arrPicsToAddPhotoUrl2)) {
                 $sem[$attr] = _PHOTOURL . $o->{$attr};
             } else {
                 $sem[$attr] = $o->{$attr};
             }
         }
         //wImage
         //kalau base
         if ($o->ArticleType == 'Base') {
             $sem['base'] = $sem;
         } else {
             $arrID = $o->BaseArticleID;
             $arr2 = $llacc->getWhere("BaseArticleID = '{$arrID}' AND ArticleType = 'Base'  LIMIT 0,1");
             $base = $arr2[0];
             $sem2 = array();
             foreach ($exp2 as $attr2) {
                 $sem2[$attr2] = $base->{$attr2};
             }
             $sem['base'] = $sem2;
         }
         $json["results"][] = $sem;
     }
     if (count($arrW) < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No Details Found";
     }
     echo json_encode($json);
     die;
 }
 public function getItems()
 {
     //        $ids = addslashes($_GET['ids']);
     //        if($ids==""){
     //            $json['status_code'] = 0;
     //            $json['status_message'] = "ID Not Found";
     //            echo json_encode($json);
     //            die();
     //        }
     //        $exp = explode(",",$ids);
     //        foreach($exp as $sss){
     //            $str[] = "ll__articletagging_with_base.TaggingLevel3ID = '$sss'";
     //        }
     //        $imp = implode(" OR ",$str);
     $basetext = "";
     if ($_GET['type'] == "base") {
         $basetext = "AND ll__article_with_image.ArticleType = 'Base'";
     }
     $ll = new LL_ArticleTagging_wbase();
     //        $whereClause = "ll__articletagging_with_base.BaseArticleID = ll__article_with_image.BaseArticleID $basetext AND ( $imp )";
     //echo $whereClause;
     $whereClause = "ll__articletagging_with_base.BaseArticleID = ll__article_with_image.BaseArticleID {$basetext} ";
     $arr = $ll->getWhereFromMultipleTable($whereClause, array("LL_Article_WImage"), "*");
     //pr($arr);
     //$arr2 = $ll->getWhere("ll__articletagging.TaggingLevel3ID = '$id'");
     //pr($arr2);
     $obj2 = new LL_Article_WImage();
     $exp2 = explode(",", $obj2->crud_webservice_allowed);
     $obj = $ll;
     $obj->default_read_coloms = $obj->crud_webservice_allowed;
     $main_id = $obj->main_id;
     $exp = explode(",", $obj->crud_webservice_allowed);
     $json = array();
     $json['status_code'] = 1;
     //filter
     foreach ($arr as $o) {
         $sem = array();
         foreach ($exp as $attr) {
             $sem[$attr] = $o->{$attr};
             foreach ($exp2 as $attr2) {
                 $sem[$attr2] = $o->{$attr2};
             }
         }
         $json["results"][] = $sem;
     }
     if ($_GET['type'] == "base" && $_GET['getvar'] == 1) {
         $arrsem = array();
         foreach ($json['results'] as $base) {
             $baseID = $base['BaseArticleID'];
             $arr5 = $obj2->getWhere("BaseArticleID = '{$baseID}'");
             foreach ($arr5 as $o) {
                 $sem = array();
                 foreach ($exp2 as $attr2) {
                     $sem[$attr2] = $o->{$attr2};
                 }
                 $base['variants'][] = $sem;
             }
             $arrsem[] = $base;
         }
         $json['results'] = $arrsem;
     }
     if (count($arr) < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No Elements Found";
     }
     echo json_encode($json);
     die;
 }
 public function scan()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $id = addslashes($_GET['id']);
     //$type = addslashes($_GET['type']);
     //if($id == "")die("no id");
     if ($id == "" || $id < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No ID";
         echo json_encode($json);
         die;
     }
     $ean = new LL_Article_EAN();
     $ean->getByID($id);
     if ($ean->var_id != "" && $ean->var_id > 0) {
         $ll = new LL_Article_WImage();
         $ll->getByID($ean->var_id);
         //        $arr = $ll->getWhere("VariantINACode = '$id' LIMIT 0,1");
         //        $sel = $arr[0];
         if ($ll->BaseArticleID != "") {
             $sel = $ll;
             $json['status_code'] = 1;
             //isi yang asli
             $obj2 = new LL_Article_WImage();
             $exp2 = explode(",", $obj2->crud_webservice_allowed);
             $sem = array();
             foreach ($exp2 as $attr2) {
                 $sem[$attr2] = $sel->{$attr2};
             }
             $json['results'] = $sem;
             //biar tidak hitung ulang
             if ($sel->ArticleType == 'Base') {
                 $json['base'] = $sem;
             } else {
                 //isi base
                 $arrID = $sel->BaseArticleID;
                 $arr2 = $ll->getWhere("BaseArticleID = '{$arrID}' AND ArticleType = 'Base'  LIMIT 0,1");
                 $base = $arr2[0];
                 $sem2 = array();
                 foreach ($exp2 as $attr2) {
                     $sem2[$attr2] = $base->{$attr2};
                 }
                 $json['base'] = $sem2;
             }
             echo json_encode($json);
             die;
         } else {
             $json['status_code'] = 0;
             $json['status_message'] = "No Results found";
             echo json_encode($json);
             die;
         }
     } else {
         $json['status_code'] = 0;
         $json['status_message'] = "No Results found";
         echo json_encode($json);
         die;
     }
 }