diff --git a/src/Controller/TYPProfileController.php b/src/Controller/TYPProfileController.php --- a/src/Controller/TYPProfileController.php +++ b/src/Controller/TYPProfileController.php @@ -1,41 +1,82 @@ redirect(""); }*/ public function profilePage($bizid){ + $address_id = ""; $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $data = \Drupal::service("typ.search")->getProfile($bizid ,AUTO); if (!$data) { return $this->redirect(""); } + /*if($data['landingpage'] == ""){ + $address_id = $data['addressid']; + } + if(is_numeric($address_id)){ + $result = \Drupal::service('typ.unvservice')->loadListing($data['customerid']); + $rs_details = (!empty($result['address'][$data['headingcod']][$address_id]['frontviews']))?$result['address'][$headingcode][$data['headingcod']]['frontviews']:array(); + } else { + $result = \Drupal::service('typ.unvservice')->loadService($data['customerid']); + }*/ + $address_id = $data['addressid']; + $result = \Drupal::service('typ.unvservice')->loadService($data['customerid']); + $rs_detail = (!empty($result['landingpages'][$data['headingcod']]))?$result['landingpages'][$data['headingcod']]:array(); + $type = ''; + if(empty($rs_detail)){ + $type = 'FL'; + }else{ + $result_olc = \Drupal::service('typ.catalog')->listData($data['customerid']); + } + unset($rs_detail); - $dataproddesct = html_entity_decode($data['proddesc']); + + $pos = strpos(html_entity_decode($data['proddesc']),"

"); + if($pos !== false){ + $tempdesc = substr(html_entity_decode($data['proddesc']),3); + }else{ + $tempdesc = html_entity_decode($data['proddesc']); + } + $temp = '

'; + $tempdesc = $temp.$tempdesc; + $type = $data['customertyp']; + + if($type == "FL") { + $dataproddesct = iconv_substr($tempdesc,0,123,"UTF-8"); + $dataproddesct .= '...'; + }else{ + $dataproddesct = $tempdesc; + } + if($type != "FL" && !empty($result_olc)){ + $olcdata = $result_olc[0]; + } // echo "

";
 //        var_export($data);
 //        exit;
         $display[] = array(
             '#theme' => 'typ_profile',
             '#profile' => $data,
             '#prodescription' => $dataproddesct,
-        );
+            '#catalog' => $olcdata,
+            '#type' => $type
+            );
         return $display;
 	}
 }
\ No newline at end of file
diff --git a/templates/typ-profile.html.twig b/templates/typ-profile.html.twig
--- a/templates/typ-profile.html.twig
+++ b/templates/typ-profile.html.twig
@@ -1,170 +1,252 @@
 {% set base_images = 'http://media.yellowpages.co.th/yellowpages'%}
 

{{ profile.custname|raw }}

หมวดหมู่ : {{ profile.headingname|raw }}
ไม่สามารถคะแนนได้

- {% trans %} Address {% endtrans %} [ + {% trans %} Address {% endtrans %} [ {% trans %}View map{% endtrans %}{{ profile.custname|raw }} ]
{{ [profile.addr,profile.soi,profile.road,profile.subdistrictname, profile.districtname,profile.cityname,profile.postcode]|join(' ') }}

-
+
{% if not profile.telno %}{% else %}{% trans %} Tel {% endtrans %}
{% endif %} {% if not profile.fax %}{% else %}{% trans %} Fax {% endtrans %}
{% endif %} {% if not profile.email %}{% else %}{% trans %} Email {% endtrans %}
{% endif %} {% if not profile.website %}{% else %}{% trans %} Website {% endtrans %}
{% endif %} {% if not profile.workinghours %}{% else %}{% trans %} Work-Time {% endtrans %}{% endif %}
-
+
{% if not profile.telno %} {% else %} - {% for key, tel in profile.telno %} - {% if loop.last != key+1 %}{{ tel }}{{ " ," }} - {% else %}{{ tel }}{% endif %} - {% endfor %}
+ {% if type == 'FL' %} + {{ profile.telno.0 }}
+ {% else %} + {% for key, tel in profile.telno %} + {% if loop.last != key+1 %}{{ tel }}{{ " ," }} + {% else %}{{ tel }}{% endif %} + {% endfor %}
+ {% endif %} {% endif %} {% if not profile.fax %} + {% else %} + {% if type == 'FL' %} + {{ profile.telno.0 }}
{% else %} - {% for key, tel in profile.fax %} - {% if loop.last != key+1 %}{{ tel }}{{ " ," }} - {% else %}{{ tel }}{% endif %} - {% endfor %}
+ {% for key, tel in profile.telno %} + {% if loop.last != key+1 %}{{ tel }}{{ " ," }} + {% else %}{{ tel }}{% endif %} + {% endfor %}
+ {% endif %} {% endif %} {% if not profile.email %} + {% else %} + {% if type == 'FL' %} + {{ profile.email }}
{% else %} - {{ profile.email }}
+ {{ profile.email }}
+ + {% endif %} {% endif %} {% if not profile.website %} {% else %} - {{ profile.website }}
+ {{ profile.website }}
{% endif %} {% if not profile.workinghours %} {% else %} {{ profile.workinghours }}
{% endif %}
{% if not prodescription %} {% else %}
{% trans %} Product And Service {% endtrans %}

- {{ prodescription|replace({"

":" ","

":" "}) }}
+ {{ prodescription|raw }}
{% endif %} {% if not profile.brandname %} {% else %}
{% trans %} Branner {% endtrans %} : {{ profile.brandname|replace({"

":" ","

":" "}) }} {% endif %}


{# TAB #} + {% if type == 'FL' %}{% else %}
+ {% if not profile.picturet1 %} + {% else %}

+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
- + {% endif %} -


- {% if not profile.custname %} - {% else %} - {{ profile.custname|raw }} : แสดงความคิดเห็น - {% endif %} -

+ {#


#} + {#{% if not profile.custname %}#} + {#{% else %}#} + {#{{ profile.custname|raw }} : แสดงความคิดเห็น#} + {#{% endif %}#} + {#

#} {# TAB #} -
- + {#
#} + {##} -
- - - -
-
+ {#
#} + {##} + {##} + {#{##}#} + {#
#} + {#
#} {# END TAB #}

- ADS +
diff --git a/typ_profile.module b/typ_profile.module --- a/typ_profile.module +++ b/typ_profile.module @@ -1,41 +1,43 @@ array( 'variables' => array( 'profile' => NULL, - 'prodescription' => NULL + 'prodescription' => NULL, + 'catalog' => NULL, + 'type' => NULL ) ) ); }