Exemple #1
0
<?php

require_once "../functions.php";
$arr = getArrayFromAPI($api_server . "/api/cat/1/materials");
$subcat_id = $_POST["subcat_id"];
$brand_id = $_POST["brand_id"];
//echo "<pre>";
//print_r($_POST);
//echo "</pre>";
//if ($brand_id){
// группируем материалы по типу и выбираем только нужную подкатегорию
$tabs = array();
$sub_cats = array();
foreach ($arr as $material) {
    if (!$sub_cats[$material["subcategory"]["id"]]) {
        $sub_cats[$material["subcategory"]["id"]] = $material["subcategory"];
    }
    if ($subcat_id && $material["subcategory"]["id"] != $subcat_id) {
        continue;
    }
    if ($brand_id && $material["brand"]["id"] != $brand_id) {
        continue;
    }
    if (!$tabs[$material["type"]["id"]]) {
        $tabs[$material["type"]["id"]] = $material["type"];
    }
    $tabs[$material["type"]["id"]]["items"][] = $material;
    //echo "<pre>";
    //print_r($material);
    //echo "</pre>";
}
Exemple #2
0
<?php

require_once "../functions.php";
//print_r($_POST);
$link = $api_server . "/api/cat/2/subcats/" . $_POST["doors_type"]["value"] . "/brands/" . $_POST["brand"]["value"] . "/serii/" . $_POST["profil-type"]["value"] . "/type/" . $_POST["profil-subtype"]["value"];
//$link = 'http://crm.vspbmebel.ru/api/cat/2/subcats/18/brands/4/serii/7/type';
$arr = getArrayFromAPI($link);
//vprint($arr);
$answer = array();
$answer["link"] = $link;
foreach ($arr as $subtype) {
    //if ($subtype["value"] == $_POST["profil-subtype"]['id']){
    foreach ($subtype['types'] as $ct => $type) {
        if (gettype($type) == 'object') {
            //$subtype['types'][$ct] = (array)$type;
            $type = (array) $type;
            $answer[$type['name']] = $type['value'];
        }
        //}
        //vprint($subtype);
    }
}
//echo "<pre>";
//print_r($answer);
//echo "</pre>";
echo json_encode($answer);
Exemple #3
0
<?php

require_once "../functions.php";
$answer = array();
//$answer = array_merge($_POST, $answer);
$answer["link"] = $api_server . "/api/cat/2/subcats/" . $_POST["doors_type"]["id"] . "/brands/" . $_POST["brand"]["id"] . "/serii/" . $_POST["profil-type"]["id"] . "/type/" . $_POST["profil-subtype"]["id"] . "/colors/" . $_POST["profil-color"]["id"] . "/materials/";
$arr = getArrayFromAPI($answer["link"]);
$answer["elements"] = $arr;
//vprint($arr);
//foreach ($arr as $subtype){
//	if ($subtype["id"] == $_POST["profil-subtype"]['id']){
//		foreach ($subtype['types'] as $ct => $type){
//			if (gettype($type) == 'object'){
//				//$subtype['types'][$ct] = (array)$type;
//				$type = (array)$type;
//				$answer[$type['name']] = $type['value'];
//			}
//		}
//
//
//		//vprint($subtype);
//	}
//}
echo json_encode($answer);
<?php

require_once "../functions.php";
$arr = getArrayFromAPI($api_server . "/api/ws");
//vprint($arr);
?>
<div class="modal-body services-choice-list">
	<div class="list-group">
		<form>
			<table class="table">
				<tr>
					<th>Название</th>
					<th>Количество</th>
				</tr>
				<?php 
foreach ($arr as $service) {
    ?>
					<tr>
						<td>
							<div class="checkbox">
								<label>
									<input
										type="checkbox"
										name="service[]"
										value="<?php 
    echo $service["id"];
    ?>
"
										data-price="<?php 
    echo $service["price"];
    ?>
            } else {
                $type = "/type";
                $sessionArrName = "api_type";
            }
        } else {
            $serii = "/serii";
            $sessionArrName = "api_serii";
        }
    } else {
        $brands = "/brands";
        $sessionArrName = "api_brands";
    }
    $url = $api_server . "/api/cat/2" . $subcats . $brands . $serii . $type . $colors . $materials;
}
//echo $url."ololo";
$options = getArrayFromAPI($url);
foreach ($options as $c => $option) {
    //if ($_POST["subcats"] == $option["id"]){
    //	$option["selected"] = "selected";
    //}
    $options[$c]["value"] = $option["id"];
    // костыль для цветов
    if ($option["hex"]) {
        $option["hex"] = preg_replace("/#/i", "", $option["hex"]);
        $options[$c]["value"] = "#" . $option["hex"];
    }
}
//print_r($options);
//$_SESSION[$sessionArrName] = $options;
?>