Language Company Category fields.
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 16 May 2012 01:54:22 +0000 (03:54 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 16 May 2012 01:54:22 +0000 (03:54 +0200)
Using the user's language to show the name of the company category fields
related to one ad.

apps/companyfront/modules/ad/actions/actions.class.php
apps/companyfront/modules/ad/templates/_list.php
apps/companyfront/modules/ad/templates/indexSuccess.php
lib/form/doctrine/AdDescriptionForm.class.php
lib/model/doctrine/CompanyCategoryDescriptionTable.class.php

index 8e78acd..dddc753 100644 (file)
@@ -51,6 +51,7 @@ class adActions extends sfActions
     $this->pager->init();
 
 
+    $this->userLanguageId = $this->getUser()->getGuardUser()->getLanguage()->getId();
     $this->languageCode = $language->getCode();
   }
 
index 09e66bd..bad7921 100644 (file)
@@ -18,7 +18,8 @@
     <?php foreach ($ads as $ad): ?>
     <tr>
       <td><img src="<?php echo $ad->getAd()->getAdMobileImageLink() ?>" alt="<?php echo $ad->getAdName() ?>"/></td>
-      <td><?php echo $ad->getAd()->getCompanyCategId() ?></td>
+      <td><?php echo CompanyCategoryDescriptionTable::getInstance()->getCategGeneralFromIdDAOImpl($userLanguageId, $ad->getAd()->getCompanyCategId())->get(0)->company_categ_name?></td>
+
       <td><?php echo $ad->getAdName() ?></td>
          <td><a href="<?php echo url_for('ad/edit?id='.$ad->getAd()->getId()) ?>"><img src="/images/pencil_add.png" alt="" title="" border="0" /></a></td>
       <td><?php echo link_to('<img src="/images/inadminpanel/images/trash.png" alt="" title="" border="0" />', 'ad/delete?id='.$ad->getAd()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?></td>
index 5c2dfd1..810802e 100644 (file)
@@ -12,7 +12,7 @@
   </table>
 </form>
 
-<?php include_partial('ad/list', array('ads' => $pager->getResults())) ?>
+<?php include_partial('ad/list', array('ads' => $pager->getResults(), 'userLanguageId' => $userLanguageId)) ?>
 
 <?php if ($pager->haveToPaginate()): ?>
   <div class="pagination">
index f2c17d0..4db1436 100644 (file)
@@ -12,7 +12,6 @@ class AdDescriptionForm extends BaseAdDescriptionForm
 {
   public function configure()
   {
-    //$this->useFields(array('language_id', 'ad_id', 'ad_name', 'ad_description', 'ad_mobile_text', 'ad_link'));
     unset($this['ad_id']);
 
     if ($this->object->exists())
index e7d82bd..c3b0ece 100644 (file)
@@ -16,4 +16,22 @@ class CompanyCategoryDescriptionTable extends Doctrine_Table
     {
         return Doctrine_Core::getTable('CompanyCategoryDescription');
     }
-}
\ No newline at end of file
+
+
+   /**
+    * Return
+    *
+    * @return Doctrine Collection
+    */
+    public function getCategGeneralFromIdDAOImpl($languageId, $companyCategId)
+    {
+         $q = Doctrine_Query::create()
+                        ->from('CompanyCategoryDescription cgd')
+                        ->where('cgd.company_categ_id = ?', $companyCategId)
+                        ->andWhere('cgd.language_id = ?', $languageId);
+
+        $doccollect=$q->execute();
+
+        return $doccollect;
+    }
+}