V-Tiger 6 How to make a Pick List with Database value - vtiger

I am very new V-Tiger CRM. What I would like to achieve is.I have a custom picklist in Create Vendor form. I know I can populate it by adding PickList Values. But I would like to fetch the Nationality from my custom database table .
My Nationality table looks like ( nationality_id nationality_name ). I need to fetch these values to custom picklist in my vendore create form

You can achive it using customization as below:
Open modules\Vendors\views\Edit.php
in process function add below code:
$sql_get = 'SELECT * FROM nationality_table_name';
$sql_get_result = $adb->query($sql_get);
for($i=0;$i<$adb->num_rows($sql_get_result);$i++){
$nationality[$i]['code'] = $adb->query_result($sql_get_result,$i,'nationality_id');
$nationality[$i]['name'] = $adb->query_result($sql_get_result,$i,'nationality_name');
}
$viewer->assign('nationality', $nationality);
parent::process($request);
2: Create new file in given location
\layouts\vlayout\modules\Vendors\uitypes\Picklist.tpl
{strip}
{assign var="FIELD_INFO" value=Zend_Json::encode($FIELD_MODEL->getFieldInfo())}
{assign var=PICKLIST_VALUES value=$FIELD_MODEL->getPicklistValues()}
{assign var="SPECIAL_VALIDATOR" value=$FIELD_MODEL->getValidator()}
{assign var=FIELD_NAME value=$FIELD_MODEL->getFieldName()}
{assign var=FIELD_NAME value=$FIELD_MODEL->getFieldName()}
{if $FIELD_NAME eq 'nationality_dropdown_name'}
<select class="chzn-select {if $OCCUPY_COMPLETE_WIDTH} row-fluid {/if}" name="{$FIELD_NAME}" data-validation-engine="validate[{if $FIELD_MODEL->isMandatory() eq true} required,{/if}funcCall[Vtiger_Base_Validator_Js.invokeValidation]]" data-fieldinfo='{$FIELD_INFO|escape}' {if !empty($SPECIAL_VALIDATOR)}data-validator='{Zend_Json::encode($SPECIAL_VALIDATOR)}'{/if} data-selected-value='{$FIELD_MODEL->get('fieldvalue')}'>
{if $FIELD_MODEL->isEmptyPicklistOptionAllowed()}<option value="">{vtranslate('LBL_SELECT_OPTION','Vtiger')}</option>{/if}
{foreach item=PICKLIST_VALUE key=PICKLIST_NAME from=$nationality}
<option value="{$PICKLIST_VALUE['code']}" {if trim(decode_html($FIELD_MODEL->get('fieldvalue'))) eq trim($PICKLIST_VALUE['code'])} selected {/if}>{$PICKLIST_VALUE['name']}</option>
{/foreach}
</select>
{/if}
{/strip}
Please update the code as per your fieldnames and test. Cheers!!

Related

Updating sql probleme with caractere

I'm sorry for my bad english, I have a little problem but i don't understand how to solve it.
When I do SQL update, I have one question mark ? which appears in the field
Here is the code
public function FooterUpdate($footer_text, $client_id) {
$connection = new Connection;
$db = $connection->openConnection();
$req = $db->prepare("UPDATE jcmsi_parametre SET footer_text = :footer_text WHERE client_id = :client_id");
$req->bindValue(':footer_text', $footer_text);
$req->bindValue(':client_id', $client_id);
$req->execute();}
The text before insert
<p><em class="fa fa-arrow-right"></em>Contact</p>
The text after insert
<p><em class="fa fa-arrow-right"></em><a href="contact.php" >Contact?</a></p>
After the insert query, I have the word Contact with the question mark ?.
I try echo $footer_text just before update and the text is ok, but not in sql
If you have an idea
Thank you
Didier

Get data from db, using multiple checkboxes in laravel 5.5

I have a table called history in which i have a column called PRODUCTS in which the products are saved.
I have a search screen with products using checkboxes, I can get the data if i use only checkbox.
How can i get data if i tick more than one checkboxes.
Displaying the checkboxes using below code
#foreach($products as $product)
#if (in_array($product->name, explode(" , ",$user->products)) !== false)
<input type="checkbox" name="products[]" value="{{$product->name}}"
#if(in_array($product->name, explode(" , ",$user->products))) #endif>
{{$product->name2}}
#endif
#endforeach
Controller
public function usersSearch(Request $request, Repair_History $query)
{
$query = $query->newQuery();
if ($request->has('products')) {
$query->where('proc_doc', $request->input('products'));
}
return $query->get();
}
Fixed it by using below code in my controller, posting as it might help someone.
$friends_checked = $request->input('products');
if (count($friends_checked) > 1 && is_array($friends_checked)) {
$query->whereIn('proc_doc', $friends_checked)
}

TYPO3 get category uid at FLUID template (sys_category)

I try to show my category uid or name as a class="category.uid" at my FLUID template.
If I try <f:debug>{data}</f:debug> I'll see there are an output like: categories => '1' (1 chars)
But how can I write the category-uid or -name into my FLUID/HTML, similar like this:
<div id="container" class="{data.nav_title}">
<!-- I need the categories -->
<div id="container" class="{categories.uid}">
THanks for your help.
EDIT: some screenshots
The info is in table sys_categorytitle, uid, pid ..
`{data}
The same problem is discussed here (see 11:30 - 12:31).
So there is no viewhelper for this. You have to register a ContentController with Flux.
I have used a variant of the solution here: How can I get the category object in Fluid of Typo3 Content Element Pictures?
TypoScript
lib.categories = CONTENT
lib.categories {
table = sys_category
select {
pidInList = root
selectFields = sys_category.uid
join = sys_category_record_mm on sys_category_record_mm.uid_local = sys_category.uid
where.field = recordUid
where.wrap = sys_category_record_mm.uid_foreign=|
}
renderObj = COA
renderObj {
1 = TEXT
1 {
field = uid
stdWrap.noTrimWrap = | cat-||
}
}
}
Fluid Template
<f:cObject typoscriptObjectPath="lib.categories" data="{recordUid: data.uid}" />
Sorry for the answer - i do not have enough reputation to comment.
What is {data}?
Is it something you get from your controller like?
$data = $this->configurationManager->getContentObject()->data;
$this->view->assign('data', $data);
If so, then you will need to do some extra processing in your controller since $data is an associated array and not an object / model with injection of relations.

Virtuemart: get PDF invoice link on order_done step

I have Joomla 2.5.17 an Virtuemart 2.0.26d. I want the PDF invoice download link on the order_done step which is rendered by order_done.php view.
I already configured the virtuemart so the order status is on "CONFIRMED" - "C" meaning as the order is paced, the PDF invoice had been already generated.
Ok, i got it. So this is what you have to do if you want the download link in order_done step. Assuming your PDFs are stored in "media/vmfiles/invoices/" you need to add some code to components/com_virtuemart/controllers/cart.php line about 477 where "else if($task=='confirm')" block starts:
...
$cart->confirmDone();
$view = $this->getView('cart', 'html');
$securePath = VmConfig::get('forSale_path',0);
$segments = explode('/', $securePath);
$folderOnServer = $segments[sizeof($segments)-3].'/'.$segments[sizeof($segments)-2];
$orderModel = VmModel::getModel('orders');
$invoiceId = $orderModel->getInvoiceNumber($cart->virtuemart_order_id);
$pdfName = "{$folderOnServer}/invoices/vminvoice_{$invoiceId}.pdf";
$view->setLayout('order_done');
$view->pdfName = $pdfName;
$view->display();
...
also a bit code in view templates/{yourtheme}/html/com_virtuemart/cart/order_done.php:
<div class="get-pdf"><?php echo JText::_('get_your_pdf'); ?> <?php echo JText::_('DOWNLOAD_PDF') ?> <br/></div>

Adding a search box to filter a list of results in Symfony?

I need to put a search box within a list of objects as a result of a typical indexSuccess action in Symfony. The goal is simple: filter the list according to a criteria.
I've been reading the Zend Lucene approach in Jobeet tutorial, but it seems like using a sledge-hammer to crack a nut (at least for my requirements).
I'm more interested in the auto-generated admin filter forms but I don't know how to implement it in a frontend.
I could simply pass the search box content to the action and build a custom query, but is there any better way to do this?
EDIT
I forgot to mention that I would like to have a single generic input field instead of an input field for each model attribute.
Thanks!
I'm using this solution, instead of integrating Zend Lucene I manage to use the autogenerated Symonfy's filters. This is the way i'm doing it:
//module/actions.class.php
public function executeIndex(sfWebRequest $request)
{
//set the form filter
$this->searchForm = new EmployeeFormFilter();
//bind it empty to fetch all data
$this->searchForm->bind(array());
//fetch all
$this->employees = $this->searchForm->getQuery()->execute();
...
}
I made a search action which does the search
public function executeSearch(sfWebRequest $request)
{
//create filter
$this->searchForm = new EmployeeFormFilter();
//bind parameter
$fields = $request->getParameter($this->searchForm->getName());
//bind
$this->searchForm->bind($fields);
//set paginator
$this->employees = $this->searchForm->getQuery()->execute();
...
//template
$this->setTemplate("index");
}
It's important that the search form goes to mymodule/search action.
Actually, i'm also using the sfDoctrinePager for paginate setting directly the query that the form generate to get results properly paginated.
If you want to add more fields to the search form check this :)
I finally made a custom form using the default MyModuleForm generated by Symfony
public function executeIndex {
...
// Add a form to filter results
$this->form = new MyModuleForm();
}
but displaying only a custom field:
<div id="search_box">
<input type="text" name="criteria" id="search_box_criteria" value="Search..." />
<?php echo link_to('Search', '#my_module_search?criteria=') ?>
</div>
Then I created a route named #my_module_search linked to the index action:
my_module_search:
url: my_module/search/:criteria
param: { module: my_module, action: index }
requirements: { criteria: .* } # Terms are optional, show all by default
With Javascript (jQuery in this case) I append the text entered to the criteria parameter in the href attribute of the link:
$('#search_box a').click(function(){
$(this).attr('href', $(this).attr('href') + $(this).prev().val());
});
And finally, back to the executeIndex action, I detect if text was entered and add custom filters to the DoctrineQuery object:
public function executeIndex {
...
// Deal with search criteria
if ( $text = $request->getParameter('criteria') ) {
$query = $this->pager->getQuery()
->where("MyTable.name LIKE ?", "%$text%")
->orWhere("MyTable.remarks LIKE ?", "%$text%")
...;
}
$this->pager->setQuery($query);
...
// Add a form to filter results
$this->form = new MyModuleForm();
}
Actually, the code is more complex, because I wrote some partials and some methods in parent classes to reuse code. But this is the best I can came up with.