-
Posts
54 -
Joined
-
Last visited
Everything posted by 244863
-
I have the following roles: Admin Client Contractor I want to create a new one called Client_site. I want this to route through to the Client prefix's but have different ACL. Basically I want it to use all the same pages, just have read only access to them. How would I set this up in the routing? Also is there anything else I will need to amend to get this working?
-
app/lib/Cake/Model/Model.php Line 1963 I wrapped the updateAll function with: if (!empty($keys[$foreignKey])) { Works a treat.
-
Hi, Addresses -> $hasMany -> Users Users -> $belongsTo -> Addresses I do not need a UserAddresses table as that would suggest a HABTM relationship which is not needed here. All I want to know is why the counterCache is trying to update when I use the $this->Model->delete() and not when I use $this->Model->save when the foreign_key is NULL???
-
Yes as I wanted to make the DB relational so I split the tables so an Address hasMany Users. This is for a building management issue logging system. So we may have 40 people that work out of one building at one address that need to log building issues. For example: My light bulb needs replacing. Thanks,
-
Sorry got myself all in a muddle, it should of read... "No, it is the counterCache which is trying to do the UPDATE. I have 3 functions in my UsersController: add which does a $this->User->save() edit which does a $this->User->save() delete which does a $this->User->delete() when I use the delete function, it deletes the User. But the counterCache tries to UPDATE the user_count field on the Addresses table with an id of NULL. The save()'s on the add / edit do not produce this error and run correctly. Hope this explains it better." Sorry.
-
Hi, No, it is the counterCache which is trying to do the UPDATE. I have 3 functions in my UsersController: add which does a $this->User->save() edit which does a $this->User->save() delete which does a $this->User->delete() when I use the delete function, it deletes the User. But the counterCache tries to UPDATE the address_count field on the Users table with an id of NULL. The save()'s on the add / edit do not produce this error and run correctly. Hope this explains it better.
-
I have just looked into it more and I only seem to get the error when deleting. It does not come up when adding / editing??
-
Any ideas on what? I have been trying everything I can think of...
-
Hi, I have a belongsTo relationship with a counterCache set correctly. The problem being that this relationship is not always there. For example Users don't always have a link to an address so the DB allows nulls. But the counterCache is always trying to update, even when the foreign key is NULL. E.g. UPDATE [addresses] SET [user_count] = 0 WHERE [id] IS N'' Is there something I can put into the counterScope to stop this error from happening on NULL id's?? Thanks in advance.
-
Hi, Tried this in my app controller's before filter: $this->Security->unlockFields = array('DocumentationDocument.site_id'); still does not work, unless I uncomment that line of code???
-
Hi, Went with this in the end. $this->set('account_status', $this->Report->query("SELECT * FROM report_account_status AS Report;")); $this->layout = 'csv/default'; Thanks,
-
Hi, The answer was because Apache was looking at a different PHP ini file, so could not connect through the command line. Thanks,
-
Here is the code for my view: <div class="column span-24"> <div class="box"> <?php echo $this->html->tag('h2', $title_for_layout); echo $this->form->create('DocumentationDocument', array('action' => 'add', 'type' => 'file')); echo $this->form->inputs(array( 'File' => array( 'type' => 'file', 'label' => __('Local File', true), 'required' => true ), 'site_id' => array( 'type' => 'hidden' ), 'site_name' => array( 'class' => 'site_name span-8', 'type' => 'text', 'required' => true, 'between' => $this->html->tag( 'div', $this->html->para('notice', __('Begin typing the site name and choose from the resultant list.', true)), array('class' => 'field-description') ) ), 'documentation_category_id' => array( 'empty' => '...', 'class' => 'span-8', 'required' => true ), 'asset_category_id' => array( 'empty' => '...', 'class' => 'span-8', 'required' => true ), 'date_produced' => array('type' => 'date') )); echo $this->html->para('notice', sprintf("Maximum file size: $size_limit")); echo $this->element('standard-form-buttons'); ?> </div> </div> <?php echo $this->element('sites', array(), array('cache' => true)); echo $this->html->scriptBlock(' $(function() { $(".site_name").autocomplete(sites, { dataType: "json", matchContains: true, mustMatch: true, parse: function(data) { return $.map(data, function(row) { return { data: row, value: row.display_name, result: row.display_name } }); }, formatItem: function(item) { return item.display_name; }, formatResult: function(item) { return item.display_name; } }).result(function(event, data, formatted) { if (data && data.id) { allSites = $(".site", $("#sites")); index = allSites.index($(this).closest(".site")); $("#DocumentationDocumentSiteId").val(data.id); $(this).siblings(".error-message").hide(100).parent().removeClass("error"); } }); }); ', array('inline' => false)); $this->Form->unlockField('DocumentationDocument.site_id'); echo $this->form->end(); ?> If I remove the following line of JS the page posts fine: $("#DocumentationDocumentSiteId").val(data.id); I am pretty sure I have the unlockedField line correct as it works on other pages. Any ideas as to why it won't post? Thanks,
-
It says the same thing: Database connection "Mysql" is missing????
-
Yes, my whole site works fine. It is just the plugin that does not like it. I have a feeling it is to do with the default database connection using a Datasource of Database/Sqlserver and the plugin not liking / finding the file location. But I'm not sure how to test / change it too????
-
I have installed the AclExtras Plugin and within the plugin have the following: public $dataSource = 'default'; my default datasource is: public $default = array( 'datasource' => 'Database/Sqlserver', 'persistent' => false, 'host' => 'IAINROSE\SQLEXPRESS', 'login' => 'administrator', 'password' => 'd3veloper', 'database' => 'clearview', 'prefix' => '', ); The rest of the app can connect and functions as normal, but when I try and run the plugin commands e.g. cake -app "c:\wamp\www\app" AclExtras.AclExtras aco_sync I get the following error: database connect Sqlserver is missing, or could not be created?? Any ideas why only the plugin can not connect??
-
I was using $this->Model->Validates() and $this->Model->Save() which validates as well. When I removed the Validates() and left just the save() everything works. Serves me right for trying to validate twice. thanks.
-
Tried that both ways. It just says the standard (Please fill out this field) from the DB as it is a required field and not the validation I stipulated below for minLength??? public $validate = array( 'description' => array( 'rule' => array('minLength', , 'message' => 'The descripton must be completed.' ) );
-
VIEW: <div class="column span-24"> <div class="box"> <?php echo $this->html->tag('h2', $title_for_layout); echo $this->form->create('Job', array('action' => 'add')); echo $this->form->inputs(array( 'description' => array( 'class' => 'span-22' ) )); echo $this->element('standard-form-buttons'); ?> </div> </div> CONTROLLER: public function add() { $this->set('title_for_layout', __('Create new Job', true)); if ($this->request->is('post')) { $this->request->data['Job']['created_by'] = $this->Auth->user('id'); unset($this->request->data['Job']['asset_category_id']); $this->Job->set($this->request->data); if ($this->Job->validates()) { $this->Job->create(); if ($this->Job->save($this->request->data, array($params = array('validate' => 'first')))) { $this->Session->setFlash('The job has been saved'); $this->redirect(array('controller' => 'jobs', 'action' => 'index')); } else { $this->Session->setFlash('The job could not be saved. Please, try again.'); } }else{ $errors = $this->ModelName->invalidFields(); } } } MODEL: <?php class Job extends AppModel { public $validate = array( 'Job.description' => array( 'notEmpty' => array( 'rule' => 'notEmpty', 'message' => 'The descripton must be completed.' ) ) ); } ?> IT won't show the validation errors on the form when I hit save??? any ideas what I am doing wrong?
-
<?php class ReportsController extends AppController { public function asset_cat_aov() { $this->set('title_for_layout', __('Asset Category Average Order Value', true)); $this->set('data', $this->Report->query("SELECT * FROM report_asset_cat_aov AS Report;")); } public function asset_aov() { $this->set('title_for_layout', __('Asset Average Order Value', true)); $this->set('data', $this->Report->query("SELECT * FROM report_asset_aov AS Report;")); } public function accrual_export() { ini_set('max_execution_time', 600); Configure::write('debug', 0); if($this->request->is('post')) { $filename = "export_".date("Y.m.d").".csv"; $results = $this->Report->query(" SELECT 'job_id', 'date', 'days', 'type', 'status', 'job_client_reference', 'site_client_reference', 'priority', 'fascia', 'address_line_4', 'postal_code', 'area_name', 'asset_category', 'asset', 'total', 'description' FROM report_accrual AS Report; "); $csv_file = fopen('php://output', 'w'); header('Content-type: application/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); $headers = array( 'ID', 'Date', 'Days', 'Type', 'Status', 'Job Ref', 'Site Ref', 'Priority', 'Fascia', 'Address', 'Postal Code', 'Area Name', 'Asset Category', 'Asset', 'Total', 'Description' ); fputcsv($csv_file,$headers,',','"'); // Each iteration of this while loop will be a row in your .csv file where each field corresponds to the heading of the column foreach($results as $result) { $row = array( $result['Report']['id'], $result['Report']['date'], $result['Report']['days'], $result['Report']['type'], $result['Report']['status'], $result['Report']['job_client_reference'], $result['Report']['site_client_reference'], $result['Report']['priority'], $result['Report']['fascia'], $result['Report']['address_line_4'], $result['Report']['postal_code'], $result['Report']['area_name'], $result['Report']['asset_category'], $result['Report']['asset'], $result['Report']['total'], $result['Report']['description'] ); fputcsv($csv_file,$row,',','"'); } fclose($csv_file); } $this->layout = false; $this->render(false); return false; } } ?> http://localhost/index.php/reports/accrual_export this link gives me a blank page, I am expecting it to give me a file download???
-
the ELSE{} $url = $this->getUrl($var); $str .= '<li ' . $selected . ' ' . $default_selected . '>'; $str .= '<a href="' . $url['url'] . '" ' . $url['target'] . '><span>' . $name . $showCarret. '</span></a>'; $str .= $sub; $str .= '</li>'; It gives me this: <a class="sf-with-ul" href="users/add">
-
if(!empty($this->url)){ $theURL = (isset($var[$this->modelName][$this->slugUrl]) && !empty($var[$this->modelName][$this->slugUrl])) ? $this->url."/".$var[$this->modelName][$this->slugUrl] : $this->url."/".$var[$this->modelName][$this->params]; $str .= '<li ' . $selected . ' ' . $default_selected . '>'; $str .= '<a href="' . $theURL . '"><span>' . $name . $showCarret. '</span></a>'; $str .= $sub; $str .= '</li>'; }else{ $url = $this->getUrl($var); $str .= '<li ' . $selected . ' ' . $default_selected . '>'; $str .= '<a href="' . $url['url'] . '" ' . $url['target'] . '><span>' . $name . $showCarret. '</span></a>'; $str .= $sub; $str .= '</li>'; }
-
Hi, when I am on a page, with a URL like: http://localhost/index.php/users/index and I have a HTML <a> tag with a href of "users/add" when I click on the link it takes me to the following URL: http://localhost/index.php/users/users/add it does not remove the controller name??? BUT when I am on: http://localhost/index.php/users/ it goes to the right URL: http://localhost/index.php/users/add any ideas welcome.
-
I have the controller below and when I use the edit page the redirect works and takes me to the right page. But when I go through the add page it does not???? <?php class GrievanceTypesController extends GrievanceAppController { function add() { $this->edit(); $this->render('edit'); } function edit($id = null) { $this->helpers = am($this->helpers, array('Form')); $grievanceTypeGroupId = $this->params['named']['grievance_type_group_id']; $this->set('grievanceTypeGroupId', $grievanceTypeGroupId); if($this->GrievanceType->GrievanceInitiation->typeHasGrievances($id) == true){ $this->flash( sprintf( __('The %s, "%s", can not be edited.', true), $this->_humanisedModelName(), $this->GrievanceType->field('title') ), array('controller' => 'grievance_type_groups', 'action' => 'view', $this->GrievanceType->field('grievance_type_group_id')) ); }else{ $this->_edit($id, array('redirect' => array('controller' => 'grievance_type_groups', 'action' => 'view', $this->GrievanceType->field('grievance_type_group_id')))); } } function delete($id = null) { if($this->GrievanceType->GrievanceInitiation->typeHasGrievances($id) == true){ $this->flash( sprintf( __('The %s, "%s", can not be deleted.', true), $this->_humanisedModelName(), $this->GrievanceType->field('title') ), array('controller' => 'grievance_type_groups', 'action' => 'view', $this->GrievanceType->field('grievance_type_group_id')) ); }else{ $this->_delete($id, array('redirect' => array('controller' => 'grievance_type_groups', 'action' => 'view', $this->GrievanceType->field('grievance_type_group_id')))); } } } ?>