Jump to content


k1000o

Member Since 09 Nov 2011
Offline Last Active Jul 09 2012 06:36 PM
-----

Topics I've Started

DefaultDataMaker from other module

08 July 2012 - 02:46 PM

Hello

I am trying to centralize all the list of values that will be used in other modules, this way it's necessary to replicate the data in each module.

For example there is a dropdown called Season that will be applied to multiple model in different modules.

I define in a module called "data" with the following DefaultDataMaker

class DatasDefaultDataMaker extends DefaultDataMaker
{
public function make()
{
  $values = array(
   '000 - No Season',
   '131 - Spring Summer 2013',
   '132 - Fall Winter 2013',
  );
  static::makeCustomFieldDataByValuesAndDefault('Seasons',
			   $values);
}
}

Then in the Materials module the field is defined in the model

'relations' => array(
'season'		   => array(RedBeanModel::HAS_ONE,   'OwnedCustomField', RedBeanModel::NOT_OWNED),
)		
....................
'customFields' => array(
'season'   => 'Seasons',
),		  
 

and in the EditAndDetailsView

array(
'elements' => array(
  array('attributeName' => 'season', 'type'		  => 'DropDown', 'addBlank'	  => true),
),
),			
	

There is no error installing and when in edit mode I even see the field but it's not populated with data, what I am missing?

Field that sum column in list view

19 June 2012 - 09:29 PM

Hello

I am trying to add a new field in the list view that makes the sum of the values in one column of the grid. Any ideas on how to achieve that?

Attached File  totals.png   13.77KB   235 downloads

Problem evaluating item->id value in Column Adapter from related list view

19 June 2012 - 07:05 AM

A new class called materials has been customized which is linked to Opportunities via a details class.
To present the data of the material in the Opportunities I created a column adapter in the material that should receive the Id of the material to present his data.

But when we are in the Opportunity we did not receive the Id of the detail we can only evaluate it in the column adapter as follows

'$data->material->id'


For some strange reason if the method __toString() of the material returns the id of the product

			$id = $this->id;
			if ($id == null || $id <= 0) {
				return Yii::t('Default',
							  '(Unnamed)');
			}
			return (string) $id;


The value is well evaluated and we can get the ID, but if the __toString() is modified to return the code and the name of the material (which is what we need)

			try {
				if (trim($this->name) == '') {
					return Yii::t('Default',
								  '(Unnamed)');
				}
				return $this->materialnum . ' - ' . $this->name;
			}
			catch (AccessDeniedSecurityException $e) {
				return '';
			}



When evaluating the expression we get something like

FAB01 - Fabric 01 name->id

Is this a bug? is there something I can do as a workaround to get the id?

Refresh Portlet via Ajax

11 June 2012 - 09:14 PM

Hello
I am trying to refresh list view portlet via ajax after deleting one of the values in the success action.
How would you approach this in zurmo?

My first approach has been to:
1) Create the getDefaultRoute method as follows

		protected function getDefaultRoute()
		{
			if (Yii::app()->request->getParam('redirectUrl') != null) {
				return Yii::app()->request->getParam('redirectUrl');
			}
			elseif (!empty($this->params["relationModelId"]) && $this->params["relationModelId"] > 0) {
				return Yii::app()->createUrl(
								$this->params["relationModuleId"] . '/' . $this->controllerId . '/details/',
								array('id'			 => $this->params["relationModelId"],
							'portletId'	  => $this->params["portletId"],
							'uniqueLayoutId' => $this->params["uniqueLayoutId"],
							'clearCache'	 => '1'
						));
			}
			else {
				return Yii::app()->createUrl($this->params["relationModuleId"] . '/' . $this->controllerId);
			}
		}

2) then in the ajax scripts use the defaultroute as the redirect to refresh the portlet
 
		protected function renderLink()
		{
			$ModelId = $this->params["relationModelId"];
			$attribName = $this->params["relationAttributeName"];
			$redirectUrl = $this->getDefaultRoute();
			return CHtml::link("CBR",
							   "#",
							   array("onclick" => "DelSelDetailFRelation (this,'$attribName','$ModelId', '$redirectUrl')", "confirm" => "Are you sure you want to delete this detail?"));
		}
 
		 protected function renderScripts()
		{
			Yii::app()->clientScript->registerScript('delSelDetailFromListViewScript',
													 "
			function DelSelDetailFRelation(element,relName, invoiceId, redirectUrl)
			{				
					$.ajax({
						url : '" . Yii::app()->createUrl('c_invoicedetails/default/DelSelFRelListFromAjax') . "'  ,
						type : 'GET',
						dataType : 'json',
						data : {'checkedIds': document.getElementById('list-view-selectedIds').value, 'relName': relName },
						success : function(data)
						{
							//refresh portlet
							window.location.href = redirectUrl;();
						},
						error : function()
						{
							//todo: error call
						}
					});
			}
		",
																																																															   CClientScript::POS_END);
		}

Where redirect URL is like this

app/index.php/c_invoicehdrs/default/details?id=2&portletId=8&uniqueLayoutId=C_invoicehdrDetailsAndRelationsViewLeftBottomView_8&clearCache=1


Thanks

View first image of Image gallery in search view

11 June 2012 - 09:26 AM

Hello
A new class called Material has been customized with an Image Gallery.

Attached File  fabric_main.png   99.26KB   218 downloads

The idea is to present in the search screen a small thumbnail of the first image in the Image Gallery. Any Idea on how to start?

Attached File  fabric_list.png   23.46KB   290 downloads

Thanks