Example #1
0
 function insert_door_to_drupal($door_id)
 {
     // set HTTP_HOST or drupal will refuse to bootstrap
     $_SERVER['HTTP_HOST'] = 'zl-apps';
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
     drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
     $door = new Door();
     $door_detail = $door->read(null, $door_id);
     $door_nid = null;
     $query = new EntityFieldQuery();
     $entities = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'doors')->propertyCondition('status', 1)->fieldCondition('field_door_id', 'value', $door_detail['Door']['id'], '=')->execute();
     foreach ($entities['node'] as $nid => $value) {
         $door_nid = $nid;
         break;
         // no need to loop more even if there is multiple (it is supposed to be unique
     }
     $node = null;
     if (is_null($door_nid)) {
         $node = new stdClass();
         $node->language = LANGUAGE_NONE;
     } else {
         $node = node_load($door_nid);
     }
     $node->type = 'doors';
     node_object_prepare($node);
     $node->title = $door_detail['Door']['door_style'];
     $node->field_door_id[$node->language][0]['value'] = $door_detail['Door']['id'];
     $node->sell_price = 0;
     $node->model = $door_detail['Door']['door_style'];
     $node->shippable = 1;
     $path = 'door/' . $node->title;
     $node->path = array('alias' => $path);
     node_save($node);
 }
 /**
  * Transforms an object (door) to a string (name).
  *
  * @param  Door|null $entity
  * @return string
  */
 public function transform($entity)
 {
     if (null === $entity) {
         return "";
     }
     return $entity->getId();
 }
<?php

require_once 'autoload.php';
$lock = new Lock('locked');
$door = new Door('closed', 'locked');
echo $door->display();
Example #4
0
<?php

include "door.php";
$door1 = new Door();
$door2 = new Door();
$door1->height = 15;
$door1->setColor("black");
//$door1->color = "black";
$door2->open();
echo "The height of door1 is: " . $door1->height;
echo "<br>The color of door1 is: " . $door1->getColor();
Example #5
0
 /**
  * Компилирует медиа файлы
  * @todo сделать возможность встройки картинок base64
  * @param array $files
  * @param type $extension
  * @return boolean|string
  * @throws Kohana_Exception 
  */
 protected function compile_media(array $files, $extension, $no_compress_scripts = array())
 {
     if (count($files) == 0) {
         return false;
     }
     $files_sum = $files;
     sort($files_sum);
     $sum = crc32(implode($files_sum));
     unset($files_sum);
     $uri = "media/{$sum}.{$extension}";
     $minified_file = DOCROOT . $uri;
     if (!file_exists($minified_file)) {
         $files_paths = array();
         foreach ($files as $file) {
             $file_path = Kohana::find_file("media", $file, $extension);
             if ($file_path === false) {
                 if (file_exists($file)) {
                     $file_path = $file;
                 } else {
                     throw new Kohana_Exception("media file '{file}.{extension}' not founded", array("{file}" => $file, "{extension}" => $extension));
                 }
             }
             $files_paths[] = array('file' => $file, 'path' => $file_path);
         }
         $sources = array();
         foreach ($files_paths as $file_path_data) {
             $file_path = $file_path_data['path'];
             $file1 = $file_path_data['file'];
             if (file_exists($file_path)) {
                 if (array_search($file1, $no_compress_scripts) === false) {
                     if ($extension == self::JS_EXT) {
                         $sources[] = "\n\n/*{$file_path}*/\n\n" . JSMin::minify(file_get_contents($file_path));
                     } else {
                         $minified_css = CssMin::minify(file_get_contents($file_path));
                         //Надо заменить относительные пути в css
                         $dir_url = Door::path_to_uri(dirname($file_path));
                         $dir_path = dirname($file_path);
                         /*if(preg_match_all("/url\\(([^\\)]+)\\)/", $minified_css, $results))
                         		{
                         			for($i = 0; $i < count($results[0]); $i++)
                         			{
                         				$url = str_replace(array('"',"'"),"",$results[1][$i]);
                         				if(strpos($url, "data:") === false)
                         				{
                         					$from = $results[0][$i];
                         					$to = "url(/".$dir_url."/".$url.")";
                         					$minified_css = str_replace($from, $to, $minified_css);
                         				}
                         			}
                         		}*/
                         if (preg_match_all("/url\\(([^\\)]+)\\)/", $minified_css, $results)) {
                             for ($i = 0; $i < count($results[0]); $i++) {
                                 $url = str_replace(array('"', "'"), "", $results[1][$i]);
                                 if (strpos($url, "data:") === false && strpos($url, "http:") === false) {
                                     $path_to_media_file = $dir_path . "/" . $url;
                                     if (!file_exists($path_to_media_file)) {
                                         continue;
                                     }
                                     $size = null;
                                     $from = $results[0][$i];
                                     $to = "";
                                     try {
                                         $size = getimagesize($path_to_media_file);
                                     } catch (Exception $e) {
                                     }
                                     if ($size !== false && filesize($path_to_media_file) < 5120) {
                                         $to = "url(\"data:{$size['mime']};base64," . base64_encode(file_get_contents($path_to_media_file)) . "\")";
                                     } else {
                                         $to = "url(/" . $dir_url . "/" . $url . ")";
                                     }
                                     $minified_css = str_replace($from, $to, $minified_css);
                                 }
                             }
                         }
                         while (preg_match_all("#url\\([^\\)]*/([^/]+)/\\.\\./#", $minified_css, $results)) {
                             for ($i = 0; $i < count($results[0]); $i++) {
                                 $minified_css = str_replace("/" . $results[1][$i] . "/../", "/", $minified_css);
                             }
                         }
                         $sources[] = "\n\n" . $minified_css;
                     }
                 } else {
                     $sources[] = file_get_contents($file_path);
                 }
             } else {
                 throw new Kohana_Exception("file '{file}' not founded", array("{file}" => $file_path));
             }
         }
         $minified = implode("", $sources);
         unset($sources);
         file_put_contents($minified_file, $minified);
     }
     return $minified_file;
 }
 function getOtherImage()
 {
     set_time_limit(0);
     $this->autoRender = false;
     $sql = "SELECT DoorStyle, ProfileOutsideImage, ProfileInsideImage FROM doorstyles";
     $datas = $this->Cabinet->query($sql);
     App::uses("Door", "Inventory.Model");
     $Door_model = new Door();
     $i = 1;
     foreach ($datas as $data) {
         $door_data = $Door_model->find('first', array('fields' => array('id', 'door_style', 'door_image', 'door_image_dir'), 'conditions' => array('Door.door_style' => $data['doorstyles']['DoorStyle']), 'recursive' => -1));
         $id = $door_data['Door']['id'];
         if (!empty($data['doorstyles']['ProfileOutsideImage'])) {
             mkdir(WWW_ROOT . 'files' . DS . 'door' . DS . 'outside_profile_image' . DS . $door_data['Door']['id'], 0777, TRUE);
             file_put_contents(WWW_ROOT . "files/door/outside_profile_image/{$id}/thumb_outside_profile_image.jpg", $data['doorstyles']['ProfileOutsideImage']);
             file_put_contents(WWW_ROOT . "files/door/outside_profile_image/{$id}/xvga_outside_profile_image.jpg", $data['doorstyles']['ProfileOutsideImage']);
             file_put_contents(WWW_ROOT . "files/door/outside_profile_image/{$id}/vga_outside_profile_image.jpg", $data['doorstyles']['ProfileOutsideImage']);
             $out_door_image_data['Door']['id'] = $door_data['Door']['id'];
             $out_door_image_data['Door']['outside_profile_image'] = "outside_profile_image.jpg";
             $out_door_image_data['Door']['outside_profile_image_dir'] = $id;
             $Door_image_model = new Door();
             $Door_image_model->save($out_door_image_data);
         }
         if (!empty($data['doorstyles']['ProfileInsideImage'])) {
             mkdir(WWW_ROOT . 'files' . DS . 'door' . DS . 'inside_profile_image' . DS . $door_data['Door']['id'], 0777, TRUE);
             file_put_contents(WWW_ROOT . "files/door/inside_profile_image/{$id}/thumb_inside_profile_image.jpg", $data['doorstyles']['ProfileInsideImage']);
             file_put_contents(WWW_ROOT . "files/door/inside_profile_image/{$id}/xvga_inside_profile_image.jpg", $data['doorstyles']['ProfileInsideImage']);
             file_put_contents(WWW_ROOT . "files/door/inside_profile_image/{$id}/vga_inside_profile_image.jpg", $data['doorstyles']['ProfileInsideImage']);
             $in_door_image_data['Door']['id'] = $door_data['Door']['id'];
             $in_door_image_data['Door']['inside_profile_image'] = "inside_profile_image.jpg";
             $in_door_image_data['Door']['inside_profile_image_dir'] = $id;
             $Door_image_model = new Door();
             $Door_image_model->save($in_door_image_data);
         }
     }
 }
Example #7
0
 /**
  * @covers Door::unlock
  * @covers AbstractDoorState::unlock
  * @expectedException IllegalStateTransitionException
  */
 public function testCannotBeUnlocked()
 {
     $this->door->unlock();
 }
 function getDoorStyleImg($door_style = null)
 {
     App::import('Model', 'Inventory.Door');
     $Door_Model = new Door();
     $data = $Door_Model->find('first', array('conditions' => array('Door.door_style' => $door_style)));
     return $data['Door']['door_image'];
 }
Example #9
0
 /**
  * @covers Door::unlock
  * @covers LockedDoorState::unlock
  * @uses   Door::isClosed
  */
 public function testCanBeUnlocked()
 {
     $this->door->unlock();
     $this->assertTrue($this->door->isClosed());
 }
function door_action_door()
{
    global $_, $conf, $myUser;
    switch ($_['action']) {
        case 'door_delete_door':
            if ($myUser->can('porte', 'd')) {
                $doorManager = new Door();
                $doorManager->delete(array('id' => $_['id']));
            }
            header('location:setting.php?section=door');
            break;
        case 'door_add_door':
            if ($myUser->can('porte', 'c')) {
                $door = new Door();
                $door->setName($_['nameDoor']);
                $door->setDescription($_['descriptionDoor']);
                $door->setPinRelay($_['pinDoorRelay']);
                $door->setPinCaptor($_['pinDoorCaptor']);
                $door->setRoom($_['roomDoor']);
                $door->save();
            }
            header('location:setting.php?section=door');
            break;
        case 'door_get_state':
            if ($myUser->can('porte', 'r')) {
                $door = new Door();
                $door = $door->getById($_['engine']);
                $cmd = '/usr/local/bin/gpio mode ' . $door->getPinCaptor() . ' in';
                system($cmd, $out);
                $cmd = '/usr/local/bin/gpio read ' . $door->getPinCaptor();
                exec($cmd, $out);
                if (!isset($_['webservice'])) {
                    echo $out[0];
                } else {
                    $affirmation = trim($out[0]) ? 'Ouvert' : 'Fermé';
                    $response = array('responses' => array(array('type' => 'talk', 'sentence' => $affirmation)));
                    $json = json_encode($response);
                    echo $json == '[]' ? '{}' : $json;
                }
            }
            break;
        case 'door_change_state':
            global $_, $myUser;
            if ($myUser->can('porte', 'u')) {
                $door = new Door();
                $door = $door->getById($_['engine']);
                $cmd = '/usr/local/bin/gpio mode ' . $door->getPinRelay() . ' out';
                system($cmd, $out);
                $cmd = '/usr/local/bin/gpio write ' . $door->getPinRelay() . ' ' . $_['state'];
                system($cmd, $out);
                //TODO change bdd state
                if (!isset($_['webservice'])) {
                    header('location:index.php?module=room&id=' . $door->getRoom());
                } else {
                    $affirmations = array('A vos ordres!', 'Bien!', 'Oui commandant!', 'Avec plaisir!', 'J\'aime vous obéir!', 'Avec plaisir!', 'Certainement!', 'Je fais ça sans tarder!', 'Avec plaisir!', 'Oui chef!');
                    $affirmation = $affirmations[rand(0, count($affirmations) - 1)];
                    $response = array('responses' => array(array('type' => 'talk', 'sentence' => $affirmation)));
                    $json = json_encode($response);
                    echo $json == '[]' ? '{}' : $json;
                }
            } else {
                $response = array('responses' => array(array('type' => 'talk', 'sentence' => 'Je ne vous connais pas, je refuse de faire ça!')));
                echo json_encode($response);
            }
            break;
    }
}
 public function calculateCabinetPriceForBuilder($cabinet_id, $cabinet_color, $material_id, $door_id, $door_color, $drawer_id, $drawer_slide_id, $quantity = 1, $delivery_option = '', $delivery_charge = 0)
 {
     App::import("Model", "Inventory.Cabinet");
     App::uses("Material", "Inventory.Model");
     App::uses("Door", "Inventory.Model");
     App::uses("Color", "Inventory.Model");
     App::import("Model", "Inventory.Item");
     App::import("Model", "Inventory.CabinetsItem");
     App::import("Model", "Inventory.InventoryLookup");
     $cabinet_id = Sanitize::escape($cabinet_id);
     $material_id = Sanitize::escape($material_id);
     $door_id = Sanitize::escape($door_id);
     $door_color = Sanitize::escape($door_color);
     $cabinet_color = Sanitize::escape($cabinet_color);
     $drawer_id = Sanitize::escape($drawer_id);
     $drawer_slide_id = Sanitize::escape($drawer_slide_id);
     $debug_calculation = '';
     $cabinets_items_model = new CabinetsItem();
     $cabinets_items_model->recursive = 1;
     $cabinets_items = $cabinets_items_model->find('all', array('conditions' => array('cabinet_id' => $cabinet_id, 'accessories' => '0')));
     $cabinets_accessories = $cabinets_items_model->find('all', array('conditions' => array('cabinet_id' => $cabinet_id, 'accessories' => '1')));
     if (!empty($cabinet_id)) {
         $cabinet = new Cabinet();
         $cabinet_detail = $cabinet->find('first', array('conditions' => array('id' => $cabinet_id)));
     }
     // predefined values
     $debug_calculation .= "Blum Up Charge = {$this->bulm_up_charge} <br />";
     $debug_calculation .= "Default Markup Factor = {$this->default_markup} <br />";
     $debug_calculation .= "<br />";
     // calculate cabinet sqft
     $item_model = new Item();
     $cabinet_sqft = $this->calculateCabinetSQFTForBuilder($cabinets_items, $item_model, $material_id);
     $debug_calculation .= "Cabinet SQFT = {$cabinet_sqft} <br />";
     $debug_calculation .= "<br />";
     // calculate cabinet sqft
     $panel_sqft = $this->calculatePanelSQFTForBuilder($cabinets_items);
     $debug_calculation .= "Panel SQFT = {$panel_sqft} <br />";
     $debug_calculation .= "<br />";
     // calculate cabinet sqft
     $box_total = $this->calculateBoxTotalForBuilder($cabinets_items, $door_id, $drawer_id, $drawer_slide_id);
     $debug_calculation .= "<b>Box Total Price = {$box_total} </b><br />";
     $debug_calculation .= "<br />";
     // get door color price
     $door_color_price = 0;
     $door_color_detail = array();
     if (!empty($door_color)) {
         $color = new Color();
         $door_color_detail = $color->find('first', array('conditions' => array('id' => $door_color)));
         if (isset($door_color_detail['ColorSection']) && !empty($door_color_detail['ColorSection']) && is_array($door_color_detail['ColorSection'])) {
             foreach ($door_color_detail['ColorSection'] as $color_section) {
                 if ($color_section['type'] == 'door_material') {
                     $door_color_price = $color_section['price'];
                     break;
                 }
             }
         }
         unset($door_color_detail);
         // clean up
         unset($color);
         // clean up
     }
     // get cabinet color price
     $cabinet_color_price = 0;
     $cabinet_price_color = 0;
     $panel_price_color = 0;
     $cabinet_color_detail = array();
     if (!empty($cabinet_color)) {
         $color = new Color();
         $cabinet_color_detail = $color->find('first', array('conditions' => array('id' => $cabinet_color)));
         if (isset($cabinet_color_detail['ColorSection']) && !empty($cabinet_color_detail['ColorSection']) && is_array($cabinet_color_detail['ColorSection'])) {
             foreach ($cabinet_color_detail['ColorSection'] as $color_section) {
                 //          if ($color_section['type'] == 'cabinet_material') {
                 if ($color_section['type'] == 'cabinate_material') {
                     $cabinet_color_price = $color_section['price'];
                     $cabinet_price_color = $cabinet_color_price * $cabinet_sqft;
                     $debug_calculation .= "Cabinet Color Price = {$cabinet_color_price} <br />";
                     $debug_calculation .= "<b>Cabinet Price (Color) = {$cabinet_price_color} </b><br />";
                     $panel_price_color = $cabinet_color_price * $panel_sqft;
                     $debug_calculation .= "<b>Panel Price (Color) = {$panel_price_color} </b><br />";
                     $debug_calculation .= "<br />";
                     break;
                 }
             }
         }
         unset($cabinet_color_detail);
         // clean up
         unset($color);
         // clean up
     }
     $doors_drawers_price = 0;
     if (!empty($door_id)) {
         $door = new Door();
         $door_detail = $door->find('first', array('conditions' => array('Door.id' => $door_id)));
         $door_cost_markup = $door_detail['Door']['cost_markup_factor'];
         $door_drawers = array();
         $debug_calculation .= "Door/Drawer Cost Markup = {$door_cost_markup} <br />";
         $debug_calculation .= "<br />";
         $door_drawers['top_door'] = array('sqft' => 0, 'price' => 0);
         if (!empty($cabinet_detail['Cabinet']['top_door_count'])) {
             $height = (double) $cabinet_detail['Cabinet']['top_door_height'];
             $width = (double) $cabinet_detail['Cabinet']['top_door_width'];
             $count = (double) $cabinet_detail['Cabinet']['top_door_count'];
             $price_sqft = (double) $door_detail['Door']['wall_door_price'];
             $price_each = (double) $door_detail['Door']['wall_door_price_each'];
             $label = 'Top Door';
             $door_drawers['top_door'] = $this->calculateDoorDrawerForBuilder($debug_calculation, $label, $height, $width, $count, $door_cost_markup, $price_sqft, $price_each);
             $debug_calculation .= "<br />";
         }
         $door_drawers['bottom_door'] = array('sqft' => 0, 'price' => 0);
         if (!empty($cabinet_detail['Cabinet']['bottom_door_count'])) {
             $height = (double) $cabinet_detail['Cabinet']['bottom_door_height'];
             $width = (double) $cabinet_detail['Cabinet']['bottom_door_width'];
             $count = (double) $cabinet_detail['Cabinet']['bottom_door_count'];
             $price_sqft = (double) $door_detail['Door']['door_price'];
             $price_each = (double) $door_detail['Door']['door_price_each'];
             $label = 'Bottom Door';
             $door_drawers['bottom_door'] = $this->calculateDoorDrawerForBuilder($debug_calculation, $label, $height, $width, $count, $door_cost_markup, $price_sqft, $price_each);
             $debug_calculation .= "<br />";
         }
         $door_drawers['top_drawer_front'] = array('sqft' => 0, 'price' => 0);
         if (!empty($cabinet_detail['Cabinet']['top_drawer_front_count'])) {
             $height = (double) $cabinet_detail['Cabinet']['top_drawer_front_height'];
             $width = (double) $cabinet_detail['Cabinet']['top_drawer_front_width'];
             $count = (double) $cabinet_detail['Cabinet']['top_drawer_front_count'];
             $price_sqft = (double) $door_detail['Door']['drawer_price'];
             $price_each = (double) $door_detail['Door']['drawer_price_each'];
             $label = 'Top Drawer Front';
             $door_drawers['top_drawer_front'] = $this->calculateDoorDrawerForBuilder($debug_calculation, $label, $height, $width, $count, $door_cost_markup, $price_sqft, $price_each, true);
             $debug_calculation .= "<br />";
         }
         $door_drawers['middle_drawer_front'] = array('sqft' => 0, 'price' => 0);
         if (!empty($cabinet_detail['Cabinet']['middle_drawer_front_count'])) {
             $height = (double) $cabinet_detail['Cabinet']['middle_drawer_front_height'];
             $width = (double) $cabinet_detail['Cabinet']['middle_drawer_front_width'];
             $count = (double) $cabinet_detail['Cabinet']['middle_drawer_front_count'];
             $price_sqft = (double) $door_detail['Door']['lower_drawer_price'];
             $price_each = (double) $door_detail['Door']['lower_drawer_price_each'];
             $label = 'Middle Drawer Front';
             $door_drawers['middle_drawer_front'] = $this->calculateDoorDrawerForBuilder($debug_calculation, $label, $height, $width, $count, $door_cost_markup, $price_sqft, $price_each, true);
             $debug_calculation .= "<br />";
         }
         $door_drawers['bottom_drawer_front'] = array('sqft' => 0, 'price' => 0);
         if (!empty($cabinet_detail['Cabinet']['bottom_drawer_front_count'])) {
             $height = (double) $cabinet_detail['Cabinet']['bottom_drawer_front_height'];
             $width = (double) $cabinet_detail['Cabinet']['bottom_drawer_front_width'];
             $count = (double) $cabinet_detail['Cabinet']['bottom_drawer_front_count'];
             $price_sqft = (double) $door_detail['Door']['lower_drawer_price'];
             $price_each = (double) $door_detail['Door']['lower_drawer_price_each'];
             $label = 'Bottom Drawer Front';
             $door_drawers['bottom_drawer_front'] = $this->calculateDoorDrawerForBuilder($debug_calculation, $label, $height, $width, $count, $door_cost_markup, $price_sqft, $price_each, true);
             $debug_calculation .= "<br />";
         }
         $door_drawers['dummy_drawer_front'] = array('sqft' => 0, 'price' => 0);
         if (!empty($cabinet_detail['Cabinet']['dummy_drawer_front_count'])) {
             $height = (double) $cabinet_detail['Cabinet']['dummy_drawer_front_height'];
             $width = (double) $cabinet_detail['Cabinet']['dummy_drawer_front_width'];
             $count = (double) $cabinet_detail['Cabinet']['dummy_drawer_front_count'];
             $price_sqft = (double) $door_detail['Door']['drawer_price'];
             $price_each = (double) $door_detail['Door']['drawer_price_each'];
             $label = 'Dummy Drawer Front';
             $door_drawers['dummy_drawer_front'] = $this->calculateDoorDrawerForBuilder($debug_calculation, $label, $height, $width, $count, $door_cost_markup, $price_sqft, $price_each, true);
             $debug_calculation .= "<br />";
         }
         //      $debug = var_export($door_drawers, true);
         //      $debug_calculation .= "Door/Drawer Price = {$debug} <br />";
         $doors_drawers_price = $this->sumDoorDrawer($door_drawers);
         $debug_calculation .= "<b>Door/Drawer Price = {$doors_drawers_price} </b><br />";
         $debug_calculation .= "<b>Bulm up Charge Total Price = {$this->bulm_up_charge_total} </b><br />";
         $debug_calculation .= "<br />";
         if ($door_color_price) {
             $debug_calculation .= "Door Color Price = {$door_color_price} <br />";
             $debug_calculation .= "<br />";
             $doors_drawers_price_color = $this->sumDoorDrawerColorForBuilder($debug_calculation, $door_drawers, $door_color_price);
             $doors_drawers_price += $doors_drawers_price_color;
             $debug_calculation .= "<br />";
             $debug_calculation .= "<b>Door/Drawer Price (Color) = {$doors_drawers_price_color} </b><br />";
             $debug_calculation .= "<br />";
         }
         unset($door);
         // clean up
     }
     $inventory_lookup = new InventoryLookup();
     $inventory_lookup->recursive = -1;
     $drawer_departments = array();
     $inventory_lookup_detail = $inventory_lookup->find('all', array('conditions' => array('InventoryLookup.lookup_type' => 'drawer')));
     foreach ($inventory_lookup_detail as $inventory_lookup_row) {
         $departments = $inventory_lookup->SearchCache2Array($inventory_lookup_row['InventoryLookup']['department_id']);
         foreach ($departments as $department) {
             if (isset($drawer_departments[$department])) {
                 $drawer_departments[$department][] = $inventory_lookup_row['InventoryLookup']['id'];
             } else {
                 $drawer_departments[$department] = array($inventory_lookup_row['InventoryLookup']['id']);
             }
         }
     }
     $item = new Item();
     $items_price = 0;
     $discount = 0;
     $items = array();
     if (!empty($cabinet_detail['CabinetsItem'])) {
         foreach ($cabinet_detail['CabinetsItem'] as $cabinet_item) {
             if ($cabinet_item['accessories']) {
                 continue;
             }
             // skip the accessories
             $item_detail = $item->find('first', array('conditions' => array('Item.id' => $cabinet_item['item_id'])));
             if (array_key_exists($item_detail['Item']['item_department_id'], $drawer_departments)) {
                 if (!in_array($drawer_id, $drawer_departments[$item_detail['Item']['item_department_id']])) {
                     continue;
                     // skip the un-selected drawer
                 }
             }
             $item_price = $item_detail['Item']['builder_price'];
             //				$item_price = $item_detail['Item']['price'];
             $ItemMaterialPrice = null;
             if (isset($material_id) && !empty($material_id)) {
                 $ItemMaterialPrice = $this->getItemMaterialPriceForBuilder($item, $cabinet_item['item_id'], $material_id, $debug_calculation);
                 $item_price = $ItemMaterialPrice['item_price'];
             }
             //Discount
             //                if( $delivery_option == '5 – 10 Weeks Delivery' ) {
             //                    $discount = $item_price * $this->default_discount;
             //                    $item_price = $item_price - $discount;
             //                }
             $item_calculated_price = $cabinet_item['item_quantity'] * $item_price;
             $items_price += $item_calculated_price;
             if ($ItemMaterialPrice['sub_item']) {
                 $debug_calculation .= "Cabinet Item ({$ItemMaterialPrice['sub_item']['Item']['item_title']}) Price = {$ItemMaterialPrice['material_data']['Material']['price']} => Quantity = {$cabinet_item['item_quantity']} => Total = {$item_calculated_price} <br />";
             } else {
                 $debug_calculation .= "Cabinet Item ({$item_detail['Item']['item_title']}) Price = {$item_price} => Quantity = {$cabinet_item['item_quantity']} => Total = {$item_calculated_price} <br />";
             }
             //        $items[] = array(
             //            'id' => $item_detail['Item']['id'],
             //            'item_title' => $item_detail['Item']['item_title'],
             //            'price' => $item_price,
             //            'base_price' => $item_detail['Item']['price'],
             //            'quantity' => $cabinet_item['item_quantity'],
             //        );
         }
         $debug_calculation .= "<b>Cabinet Item Price = {$items_price} </b><br />";
         $debug_calculation .= "<br />";
         unset($cabinet_detail);
         // clean up
     }
     $total_price = ($items_price + $cabinet_price_color + $panel_price_color + $doors_drawers_price + $this->bulm_up_charge_total) * $this->default_markup * $quantity;
     $discount_rate = $this->getProductionTime($delivery_option);
     $discount = $total_price * $discount_rate;
     $total_price = $total_price - $discount;
     $debug_calculation .= "<b>Discount = {$discount} </b><br />";
     $debug_calculation .= "<b>Total Price = {$total_price} </b><br />";
     $result = array('items_price' => $items_price, 'doors_price' => $doors_drawers_price, 'cabinet_color_price_color' => $cabinet_price_color, 'total_price' => $total_price, 'debug_calculation' => $debug_calculation, 'conditions' => array('resource_id' => $cabinet_id, 'resource_type' => 'cabinet', 'material_id' => $material_id, 'door_id' => $door_id, 'door_color' => $door_color, 'cabinet_color' => $cabinet_color, 'drawer_slide_id' => $drawer_slide_id, 'drawer_id' => $drawer_id, 'quantity' => $quantity));
     return $result;
 }