pad_base_multi Class Reference

extends class pad_base, but for used in listing product, and the product_quantity id css id :

  • product_quantity_xx
  • xx is the products id
More...

Inherits pad_base.

List of all members.

Public Member Functions

Public Attributes

Protected Member Functions


Detailed Description

extends class pad_base, but for used in listing product, and the product_quantity id css id :

  • product_quantity_xx
  • xx is the products id

Definition at line 21 of file pad_base_multi.php.


Member Function Documentation

pad_base_multi::_draw_attributes ( attrib  )  [protected]

Boucle pour la mise en html des attribute.

Parameters:
$attrib array tableau attribute
Returns:
: HTML for displaying the product attributes

option non obligatoire

gestion stock

boucle adapt sortie

js exe inline

Reimplemented from pad_base.

Definition at line 41 of file pad_base_multi.php.

00041                                                {
00042     $out='';
00043     $o=0;
00044     $mode_img=array();
00045 
00046     foreach($attrib as $item) {
00048       if($item['omode']==0) $item['default']='';
00049 
00051       $stocked=($item['ostock']==0)? false : true;
00052 
00054       for ($a=0, $s=sizeof($item['ovals']); $a<$s; $a++) {
00055         $mode_img[]=$mod=(!empty($item['ovals'][$a]['thumbnail'])? true : false);
00056         $item['ovals'][$a]['text']=($mod)? tep_image($item['ovals'][$a]['thumbnail'], $item['ovals'][$a]['text']):$item['ovals'][$a]['text'];
00057         $mode_url[]=(!empty($item['ovals'][$a]['url'])? true : false);
00058       }
00059 
00061       $js =" onchange=\" ";
00062 //       $js.=(in_array(true,$mode_url)) ? " up_master_image_".$this->products_id."(this.value); " : "";
00063       $js.=(in_array(true,$mode_url))  ? " up_master_image_".$this->products_id."(".$item['oid'].",this.value); " : "";
00064       $js.=($this->actual_price_pull_down) ? " up_master_price_".$this->products_id."(".$item['oid'].",this.value); " : "";
00065       if($stocked) $js.=($this->stock_check && $this->out_of_stock_msgline) ? " stkmsg_".$this->products_id."(this.form);  " : "";
00066       $js.=" \" ";
00067 
00068 
00069       $out.='<li class="product_option_item">'.
00070             '<span class="item_heading"><strong>'.$item['oname'].':</strong></span>'.
00071             '<span class="item_comment">'.$item['ocomment'].'</span>'.
00072             '<span class="item_value">'.$this->_draw_type_att($item, $js).'</span>'.
00073             "</li>\n";
00074 
00075       $this->up_master=$o;
00076       $o++;
00077     }
00078     return $out.$this->_draw_out_of_stock_message_js($attrib);
00079   }

pad_base_multi::_draw_out_of_stock_message_js ( attributes  ) 

draw Javascript to display out of stock message for out of stock attribute combinations

Parameters:
array $attributes Array of attributes for the product. Format is as returned by _build_attributes_array.
Returns:
: string: Javascript to display out of stock message for out of stock attribute combinations

Reimplemented from pad_base.

Definition at line 92 of file pad_base_multi.php.

00092                                                       {
00093     $out='';
00094 
00095     $out.="<li><span id=\"oosmsg_".$this->products_id."\" class=errorBox></span>\n";
00096 // print_r($attributes);
00097 
00098     if (($this->out_of_stock_msgline | $this->no_add_out_of_stock)) {
00099 
00100       $combinations = array();
00101       $selected_combination = 0;
00102       $this->_build_attributes_combinations($attributes, $this->show_out_of_stock, 'None', $combinations, $selected_combination);
00103 
00104       $out.="<script type=\"text/javascript\"><!--\n";
00105       $out.="  function check_test_".$this->products_id."(input) {\n \n  ";
00106       $out.="   if(input.type =='select-one'){  ";
00107       $out.="    var selected_value = input.selectedIndex;  \n  ";
00108       $out.="    return input[selected_value].value;  \n  ";
00109       $out.="   } else {  \n  ";
00110       $out.="     for (var i=0; i<input.length;i++) { \n";
00111       $out.="       if (input[i].checked || input[selected_value]) return input[i].value;  \n";
00112       $out.="     } \n";
00113       $out.="    } \n";
00114       $out.="   } \n";
00115       $out.="  function chkstk_".$this->products_id."(frm) {\n";
00116 
00117       // build javascript array of in stock combinations
00118       $out.="    var stk=".$this->_draw_js_stock_array($combinations).";\n";
00119       $out.="    var instk=false;\n";
00120       $out.="    if(frm ==null)  return ''; \n";
00121 
00122       // build javascript if statement to test level by level for existance
00123       $out.=' var qty = document.getElementById("products_quantity_'.$this->products_id.'").value ;   ';
00124         for ($i=0; $i<sizeof($attributes); $i++) {
00125           $out.=' var input'.$i." = frm.elements['id[".$attributes[$i]['oid']."]']; \n";
00126           $out.=" var val".$i." =check_test_".$this->products_id."(input".$i."); ";
00127         }
00128       $out.="\n".'if( stk';
00129         for ($i=0; $i<sizeof($attributes); $i++) {
00130           $out.="[val".$i."]";
00131         }
00132       $out.=' >=  qty ) return true; '."\n";
00133       $out.='else return false;';
00134       $out.="  }\n";
00135 
00136 
00137 
00138       if ($this->out_of_stock_msgline) {
00139         // set/reset out of stock message based on selection
00140         $out.="  function stkmsg_".$this->products_id."(frm) {\n";
00141         $out.="    var instk=chkstk_".$this->products_id."(frm);\n";
00142         $out.="    var span=document.getElementById(\"oosmsg_".$this->products_id."\");\n";
00143         $out.="    while (span.childNodes[0])\n";
00144         $out.="      span.removeChild(span.childNodes[0]);\n";
00145         $out.="    if (!instk)\n";
00146         $out.="      span.appendChild(document.createTextNode(\"".addslashes(TEXT_OUT_OF_STOCK_MESSAGE)."\"));\n";
00147         $out.="    else\n";
00148         $out.="      span.appendChild(document.createTextNode(\" \"));\n";
00149         $out.="  }\n";
00150         //initialize out of stock message
00151 //         $out.="  stkmsg(document.forms.cart_quantity);\n";
00152       }
00153 
00154       if ($this->no_add_out_of_stock) {
00155         // js to not allow add to cart if selection is out of stock
00156         $out.="  function chksel_".$this->products_id."() {\n";
00157         $out.="    var instk=chkstk_".$this->products_id."(document.forms.cart_quantity_".$this->products_id.");\n";
00158         $out.="    if (!instk) alert('".TEXT_OUT_OF_STOCK_MESSAGE."');\n";
00159         $out.="    return instk;\n";
00160         $out.="  }\n";
00161 //         $out.="  document.id_" . (int)$this->products_id . ".onsubmit=chksel;\n";
00162         $out.="  document.forms.cart_quantity_".$this->products_id.".onsubmit=chksel_".$this->products_id.";\n";
00163       }
00164       $out.="//--></script>\n";
00165     }
00166     $out.="</li>\n";
00167     return $out;
00168   }

pad_base_multi::_draw_price_master ( attributes  )  [protected]

Remplacement de l'image principale du produits.

Parameters:
$attributes array

Reimplemented from pad_base.

Definition at line 200 of file pad_base_multi.php.

00200                                                      {
00201     global $osCSS_Cache;
00202     $i=$this->up_master;
00203     if ($osCSS_Cache->read('_draw_price_master-'.$this->products_id.'-ctr_js', 60) ) {
00204       $out = $osCSS_Cache->getCache();
00205     } else {
00206     $out="<script type=\"text/javascript\"><!--\n";
00207 
00208     $out.="function up_master_price(idn,id_value){\n";
00209     $out.=" var master2 =  document.getElementById('price_master');\n";
00210     $tableau_JS="Tableau2";
00211     $out.= sprintf("%s = new Array();\n",$tableau_JS);
00212       for($i=0, $m=count($attributes); $i< $m; $i++){
00213         $out.=  sprintf("%s[%s]= new Array();\n",$tableau_JS, $i);
00214         foreach($attributes[$i]['ovals'] as $keyItems => $valueItems) {
00215           $out.=  sprintf("%s[%s][%s]= new Array();\n",$tableau_JS,$i, $keyItems);
00216           foreach($valueItems as $keyItem => $valueItem) {
00217             $out.=  sprintf("%s[%s][%s]['%s'] =%s;\n",$tableau_JS, $i, $keyItems, $keyItem,
00218                      ( is_string($valueItem)||empty($valueItem) ) ?  "\"".addslashes($valueItem)."\"" : $valueItem);
00219           }
00220         }
00221       }
00222 //     $out.=" var pile_price = parseFloat(".$tableau_JS."[idn][i]['adjust']);\n";
00223 //     $out.=" var pile_prefix=".$tableau_JS."[idn][i]['prefix'] ;\n";
00224     $out.="  idn= (idn-1) ;\n";
00225     $out.="  tab = ".$tableau_JS."[idn] ;\n";
00226     $out.=" var actuel = parseFloat(master2.innerHTML) ;\n";
00227 //     $out.="   if ( pile_price != actuel ){;\n";
00228 //     $out.="  if(pile_prefix == '-' )  actuel = parseFloat(master2.innerHTML)+ parseFloat(pile_price) ;\n";
00229 //     $out.="  else actuel = parseFloat(master2.innerHTML)-parseFloat(pile_price) ;\n";
00230 //     $out.="   }else actuel = parseFloat(master2.innerHTML);\n";
00231     $out.="  actuel = parseFloat(master2.innerHTML);\n";
00232     $out.=" for(i=0; i<tab.length; i++) { \n
00233               if(i==0)actuel = parseFloat(".$tableau_JS."[idn][i]['original_price']) ; \n
00234               if(".$tableau_JS."[idn][i]['id']==id_value ){\n
00235                 if(".$tableau_JS."[idn][i]['prefix'] == '+' ) master2.innerHTML=actuel+  parseFloat(".$tableau_JS."[idn][i]['adjust']) ;\n
00236                 else master2.innerHTML= actuel -  ".$tableau_JS."[idn][i]['adjust'] ;\n
00237                 pile_price = ".$tableau_JS."[idn][i]['adjust'] ;\n
00238                 pile_prefix = ".$tableau_JS."[idn][i]['prefix'] ;\n
00239               }\n
00240             } \n";
00241     $out.="}\n";
00242     $out.="//--></script>\n";
00243 
00244       $osCSS_Cache->writeBuffer($out);
00245     }
00246 
00247     return $out;
00248   }

pad_base_multi::_draw_upimage_master ( attributes  )  [protected]

Reimplemented from pad_base.

Definition at line 175 of file pad_base_multi.php.

00175                                                        {
00176     $i=$this->up_master;
00177     $out="<script type=\"text/javascript\"><!--\n";
00178     $out.="function up_master_image_".$this->products_id."(idn,id_value){\n";
00179     $tableau_JS="Tableau";
00180     $out.= sprintf("%s = new Array();\n",$tableau_JS);
00181         foreach($attributes[$i]['ovals'] as $keyItems => $valueItems) {
00182           foreach($valueItems as $keyItem => $valueItem) {
00183             if($keyItem=='id') $id=$valueItem;
00184             elseif($keyItem=='url')
00185                 $out.=  sprintf("%s[%s] = %s;\n",$tableau_JS, $id,
00186                      ( is_string($valueItem)||empty($valueItem) ) ?  "\"".addslashes($valueItem)."\"" : $valueItem);
00187           }
00188         }
00189     $out.=" change_image_master_".$this->products_id."('".HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_IMAGES."'+".$tableau_JS."[id_value]) ;\n ";
00190     $out.="}\n";
00191     $out.="//--></script>\n";
00192     return $out;
00193   }

pad_base_multi::_js_draw_textoption (  )  [protected]

Calcul nombre caratere restant / specifique option text champs dipso pour user.

Reimplemented from pad_base.

Definition at line 256 of file pad_base_multi.php.

00256                                           {
00257     global $osCSS_Cache;
00258     if ($osCSS_Cache->read('__js_draw_textoption-'.$this->products_id.'-ctr_js', 60) ) {
00259       $out = $osCSS_Cache->getCache();
00260     } else {
00261 
00262     $out ="<script language=\"javascript\"><!--\n";
00263     $out.=" // BOF Product Type Feature\n";
00264     $out.=" function textCounter(field,counter,maxlimit,linecounter) {\n";
00265         $out.="     // text width//\n";
00266         $out.="     var fieldWidth =  parseInt(field.offsetWidth);\n";
00267         $out.="     var charcnt = field.value.length;\n";
00268         $out.="     // trim the extra text\n";
00269         $out.="     if (charcnt > maxlimit) {\n";
00270         $out.="             field.value = field.value.substring(0, maxlimit);\n";
00271         $out.="     } else {\n";
00272         $out.="     // progress bar percentage\n";
00273         $out.="     var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;\n";
00274         $out.="     document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+\"px\";\n";
00275         $out.="     document.getElementById(counter).innerHTML=\"Limit: \"+percentage+\"%\"\n";
00276         $out.="     // color correction on style from CCFFF -> CC0000\n";
00277         $out.="     setcolor(document.getElementById(counter),percentage,\"background-color\");\n";
00278         $out.="     }\n";
00279     $out.=" }\n";
00280     $out.=" function setcolor(obj,percentage,prop){\n";
00281         $out.="     obj.style[prop] = \"rgb(80%,\"+(100-percentage)+\"%,\"+(100-percentage)+\"%)\";\n";
00282     $out.=" }\n";
00283     $out.=" // EOF Product Type Feature\n";
00284     $out.=" //-->\n";
00285     $out.="</script>\n";
00286 
00287       $osCSS_Cache->writeBuffer($out);
00288     }
00289 
00290     return $out;
00291   }


Member Data Documentation

pad_base_multi::$mark_out_of_stock

Reimplemented from pad_base.

Definition at line 27 of file pad_base_multi.php.

pad_base_multi::$no_add_out_of_stock

Reimplemented from pad_base.

Definition at line 29 of file pad_base_multi.php.

pad_base_multi::$out_of_stock_msgline

Reimplemented from pad_base.

Definition at line 28 of file pad_base_multi.php.

pad_base_multi::$products_id

Reimplemented from pad_base.

Definition at line 24 of file pad_base_multi.php.

pad_base_multi::$products_tax_class_id

Reimplemented from pad_base.

Definition at line 25 of file pad_base_multi.php.

pad_base_multi::$show_out_of_stock

Reimplemented from pad_base.

Definition at line 26 of file pad_base_multi.php.


The documentation for this class was generated from the following file: