I was wondering if you had any thoughts about this issue: We want to add one more status at a specific 'place' between two statuses, but we ran out of enumeration for it.
The enumeration looks like this:
$s_status_enum_string = "10:new,20:feedback,40:confirmed,50:assigned,52:in progress,53:code review pending,54:merge pending, 56:merged, 58:resolved, 60:testing, 70:tested, 90:closed, 91:updating test documentation";
And I want to add a new status between 52 and 53 so that, on the pull-down menu for status, they appear in the desired order.
I tried different things - including changing the .php file definitions then updating the MySQL table's status field in mantis_bug_table, but it messes up all the views and filters.
Any ideas?
The following steps might help you:
Redefine the enumeration string as per your requirements
Prepare a traceability with your current enumeration values
Update the status field in bugs table with the new values
Add the enumeration in config.php
You may have to reset your previous filters. The filter criteria is stored as a serialized string and it's very difficult to modify.
If anyone is having issues with this you need to change the following:
In config_inc.php modify $g_status_enum_string to ennumerate the new statuses as you see fit.
In custom_constants_inc.php make sure to do the same as above.
In the database, run SQL commands such as this:
UPDATE mantisclone.mantis_bug_table SET status=100 WHERE status=10;
to change the actual records for existing status IDs to new ones.
In custom_strings_inc.php modify $s_status_enum_string and input your new statuses. For example one of mine was:
$s_sanity_test_bug_title = "Set Issue Sanity Test";
$s_sanity_test_bug_button = "Issue Sanity Test Pending";
$s_email_notification_title_for_sanity_test = "The following issue is NOW SANITY TEST PENDING";
Finally you'll need a small script to change the existing ennumerated values in mantis_filters_table. This was mine, alter it as you see fit:
<?php
$mantisDB="myMantisDatabaseName";
mysql_connect("localhost", "XXXX", "YYYY") or die("Could not connect: " . mysql_error());
mysql_select_db($mantisDB);
$result = mysql_query("SELECT id, filter_string FROM $mantisDB.mantis_filters_table");
function parseRecord($statusArray)
{
$newStatus = array( "10" => "100",
"20" => "200",
"50" => "300",
"52" => "400",
"53" => "500",
"54" => "540",
"56" => "560",
"58" => "580",
"60" => "600",
"70" => "700",
"75" => "450",
"90" => "900",
"91" => "910"
);
foreach ($statusArray as $key=>$value)
{
if(array_key_exists($value, $newStatus))
{
echo "Found value $value, replacing it with " . $newStatus[$value] . "\n";
$statusArray[$key] = (int)$newStatus[$value];
}
}
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$statusID = $row["id"];
$serializedString = $row["filter_string"];
$unserializedArray = unserialize(substr($serializedString,3)); // There's a prepended 'v8#' string in there, don't know why.
parseRecord(&$unserializedArray["hide_status"]);
parseRecord(&$unserializedArray["show_status"]);
$newSerialized = "v8#".serialize($unserializedArray);
// echo $newSerialized;
$changeStatus = mysql_query("UPDATE $mantisDB.mantis_filters_table SET filter_string='$newSerialized' WHERE id=$statusID");
}
mysql_free_result($result);
?>
I hope this works, let me know if you're having any issues.
Related
I am generating a grid from a view querying multiple tables. I need to add a column that will be edited by the user by entering an amount so that the row can save as a new record in a couple of tables. This is why the column is not really generated in the database, since there is not really a record that contains that amount.
#(Html.EJ().Grid<object>("ITEMS_PRESUPUESTOGrid")
.Datasource(ds => ds.URL("GetOrderData_VISTA_ITEMS_PRESUPUESTO_ACTIVO").Adaptor(AdaptorType.UrlAdaptor))
//.AllowScrolling()
//.ScrollSettings(col => { col.Width(520).Height(300).EnableVirtualization(true); })
.AllowPaging()
.AllowFiltering()
.QueryString("COD_SUBCAPITULO")
.Locale("es-CO")
.AllowResizeToFit(true)
.AllowResizing(false)
.AllowMultiSorting()
.AllowSorting()
.PageSettings(page => page.PageSize(7))
.ClientSideEvents(eve => eve.ToolbarClick("clickedderecha"))
.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Normal); })
.ClientSideEvents(e => e.Load("load_VISTA_ITEMS_PRESUPUESTO_ACTIVOGrid").Create("create_grid_ITEMS_PRESUPUESTOGrid").ActionBegin("inicio").ActionBegin("inicio_grid_VISTA_ITEMS_PRESUPUESTO_SIN_CONTRATOGrid").Create("create_grid_VISTA_ITEMS_PRESUPUESTO_SIN_CONTRATOGrid"))
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Search);
});
}).Columns(col =>
{
col.Field("COD_ITEM").HeaderText("CÓDIGO").IsPrimaryKey(true).Visible(true).Add();
col.Field("NOMBRE").HeaderText("NOMBRE").Add();
col.Field("CANTIDAD").HeaderText("C. PRESU.").Add();
col.HeaderText("C. A REG").EditType(EditingType.NumericEdit).Add();
})
to edit the data in the template (client side) I am trying with: .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Normal); }) but i don't know how to see these changes reflected. enter image description here after editing it is not saving the entered value.
The column in reference is the last one. At this time, first it is not taking the default value and it is not saving the value that I enter when I edit the column.
I have not yet created the function to save the data in the database because first I want to get to modify the data in the template.
This is the code for the database view:
CREATE VIEW [dbo].[VISTA_ITEMS_PRESUPUESTO_ACTIVO]
AS
SELECT
dbo.ITEMS_PRESUPUESTO.COD_ITEM,
dbo.ITEMS_PRESUPUESTO.NOMBRE, dbo.ITEMS_PRESUPUESTO.CANTIDAD,
dbo.PRESUPUESTOS_ITEM_PRESUPUESTO.COD_PRESUPUESTO_ITEM_PRESUPUESTO,
dbo.PRESUPUESTOS_ITEM_PRESUPUESTO.COD_PRESUPUESTO,
dbo.PRESUPUESTOS.COD_PROYECTO,
0 AS CANTIDAD_ACTIVIDAD
FROM
dbo.ITEMS_PRESUPUESTO INNER JOIN
dbo.PRESUPUESTOS_ITEM_PRESUPUESTO ON dbo.ITEMS_PRESUPUESTO.COD_ITEM = dbo.PRESUPUESTOS_ITEM_PRESUPUESTO.COD_ITEM
INNER JOIN
dbo.PRESUPUESTOS ON dbo.PRESUPUESTOS_ITEM_PRESUPUESTO.COD_PRESUPUESTO = dbo.PRESUPUESTOS.COD_PRESUPUESTO
INNER JOIN
dbo.PROGRAMAS ON dbo.PROGRAMAS.COD_PROYECTO = dbo.PRESUPUESTOS.COD_PROYECTO
WHERE (dbo.ITEMS_PRESUPUESTO.COD_ESTADO_ITEM_PRESUPUESTO = 1) AND (dbo.PRESUPUESTOS.COD_ESTADO_PRESUPUESTO = 5)
and this is the controller:
public ActionResult GetOrderData_VISTA_ITEMS_PRESUPUESTO_ACTIVO(DataManager dm)
{
IEnumerable DataSource = db.VISTA_ITEMS_PRESUPUESTO_ACTIVO.ToList();
DataOperations ds = new DataOperations();
List<string> str = new List<string>();
db.Configuration.ProxyCreationEnabled = false;
db.Configuration.LazyLoadingEnabled = false;
return Json(new { result = DataSource }, JsonRequestBehavior.AllowGet);
}
if someone can help me I am very grateful
strong text
I found a solution in the official documentation
}).Columns(col => {
col.Type("checkbox").HeaderText("").Field("").Width("60").AllowFiltering(false).AllowSorting(false).Add();
col.Field("COD_ITEM").HeaderText("CÓDIGO").IsPrimaryKey(true).Visible(false).col.Field("NOMBRE").HeaderText("NOMBRE").Add();
col.Field("CANTIDAD").HeaderText("C. DISPONIBLE").Add();
col.HeaderText("C. ADD").Template("<input value=0 />").Add();
I added two editable fields, the check one and an input, I share the links to expand the information:
https://help.syncfusion.com/aspnetmvc/grid/columns?cs-save-lang=1&cs-lang=razor
https://help.syncfusion.com/aspnetmvc/grid/editing?_ga=2.162224380.1153013492.1605824141-52632355.1601061767#default-column-values-on-add-new
Based on your sample, the last column has no field properties. So the last column displays the empty value. Based on your query, you are using Multiple table to generate grid. So we suggest that you use foreign key column. Please refer to the below code snippet:
Your code:
col.Field("NOMBRE").HeaderText("NOMBRE").Add();
col.Field("CANTIDAD").HeaderText("C. PRESU.").Add();
col.HeaderText("C. A REG").EditType(EditingType.NumericEdit).Add();
.
Modified code:
col.Field("OrderID").HeaderText("CÓDIGO").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("NOMBRE").TextAlign(TextAlign.Right).EditType(EditingType.NumericEdit).Width(75).Format("{0:C}").Add();
col.Field("ShipCity").HeaderText("C. PRESU.").Width(80).Add();
col.Field("EmployeeID").HeaderText("C. A REG").ForeignKeyField("EmployeeID").ForeignKeyValue("FirstName").DataSource(ViewBag.data).TextAlign(TextAlign.Right).Width(90).Add();
Please refer to the below help documentation:
https://help.syncfusion.com/aspnetmvc/grid/columns#foreign-key-column
Please refer to the modified sample:
https://www.syncfusion.com/downloads/support/directtrac/304148/ze/Grid-sample-627225723
I have my app in Zapier CLI. I have created a trigger to set dropdown values for a particular action step during zap creation.
The data comes like this :
{ "data": {
"account_status": {
"field_name": "account_status",
"field_label": "Status",
"field_type": "list",
"field_length": "50",
"field_items": "Active|Inactive|444|Closed",
"required": "0",
"related_module": "",
"related_field_name": "",
"join_table": "",
"join_lhs_field_name": "",
"join_rhs_field_name": "",
"related_data_field": ""
},
}
}
Here is my code:
Now I am trying to set the data for the dynamic dropdown using field_items value from the above result like this:
return responsePromise
.then(response => JSON.parse(response.content ) )
.then(data => {
const account_status_list = data.data.account_status.field_items;
const account_status_arr = account_status_list.split("|");
return account_status_arr.map(function(e){
e.id = e
return e
})
})
my input field for the dynamic dropdown trigger is:
{
key: 'account_status',
label:'Account Status',
required: false,
dynamic: 'account_status.account_dropdown.id'
}
On clicking the dropdown I get this error
Can anyone suggest where I am going wrong or what may I do to resolve this ?
David here, from the Zapier Platform team.
The issue is that Zapier expects an array of objects and you're returning an array of strings. It seems like you're trying to make an id field in your code snippet, but calling "Active".id = "Active" won't make an object.
Instead, you should change your map function to be something like the following:
return account_status_arr.map(function(e){
return {id: e}
})
The other thing you'll probably need to tweak is how your dynamic dropdown is set up. It's a period-separated string that follows the format trigger_key.id_key.label_key. The id and label can be the same key; it really depends on what data you need to send to the API (the label is just for show, the id is what's actually sent). In the dynamic field, you'll have a dyanmic property that'll be account_status.id.id.
There are docs here.
ZF2 docs show the following example in terms of using Db\RecordExists validator with multiple columns.
$email = 'user#example.com';
$clause = $dbAdapter->quoteIdentifier('email') . ' = ' . $dbAdapter->quoteValue($email);
$validator = new Zend\Validator\Db\RecordExists(
array(
'table' => 'users',
'field' => 'username',
'adapter' => $dbAdapter,
'exclude' => $clause
)
);
if ($validator->isValid($username)) {
// username appears to be valid
} else {
// username is invalid; print the reason
$messages = $validator->getMessages();
foreach ($messages as $message) {
echo "$message\n";
}
}
I’ve tried this using my own Select object containing a more complex where condition. However, isValid() must be called with a value parameter.
In the example above $username is passed to isValid(). But there seems to be no according field definition.
I tried calling isValid() with an empty string, but this does not produce the desired result, since Zend\Validator\Db\AbstractDb::query() always adds the value to the statement:
$parameters = $statement->getParameterContainer();
$parameters['where1'] = $value;
If I remove the seconds line above, my validator produces the expected results.
Can someone elaborate on how to use RecordExists with the where conditions in my custom Select object? And only those?
The best way to do this is probably by making your own validator that extends one of Zend Framework's, because it doesn't seem like the (No)RecordExists classes were meant to handle multiple fields (I'd be happy to be proven wrong, because it'd be easier if they did).
Since, as you discovered, $parameters['where1'] is overridden with $value, you can deal with this by making sure $value represents what the value of the first where should be. In the case of using a custom $select, $value will replace the value in the first where clause.
Here's a hacky example of using RecordExists with a custom select and multiple where conditions:
$select = new Select();
$select->from('some_table')
->where->equalTo('first_field', 'value1') // this gets overridden
->and->equalTo('second_field', 'value2')
;
$validator = new RecordExists($select);
$validator->setAdapter($someAdapter);
// this overrides value1, but since isValid requires a string,
// the redundantly supplied value allows it to work as expected
$validator->isValid('value1');
The above produces the following query:
SELECT `some_table`.* FROM `some_table` WHERE `first_field` = 'value1' AND `second_field` = 'value2'
...which results in isValid returning true if there was a result.
I have a problem with ZF2 RecordExists method. I will explain my problematic case/scenario.
Table: users
Columns: id, emailaddress, websitename
Sample Records:
1, user1#email.com, 1site.com
2, user2#email.com, 1site.com
3, user3#email.com, 2site.com
4, user4#email.com, 2site.com
5, user5#email.com, 1site.com
6, user6#email.com, 3site.com
7, user7#email.com, 4site.com
I am using the following snippet for already exist condition.
//Check that the email address exists in the database
$validator = new Zend\Validator\Db\RecordExists(
array(
'table' => 'users',
'field' => 'emailaddress'
)
);
if ($validator->isValid($emailaddress)) {
// email address appears to be valid
} else {
// email address is invalid; print the reasons
foreach ($validator->getMessages() as $message) {
echo "$message\n";
}
}
As per the above snippets, user1#email.com cannot register again. Because, that emailaddress is exist in table.
But, i would like to do register with 2site.com. Because, user1#email.com is in 1site.com.
So, user1#email.com cannot register with 1site.com again. But, user1#email.com can register with 2site.com.
How is it possible? Let me know your suggestions.
There are two way to do this.
First using Excluding Record methods
Where you exclude the record of websitename field value.
Zend\Validator\Db\RecordExists and Zend\Validator\Db\NoRecordExists
also provide a means to test the database, excluding a part of the
table, either by providing a where clause as a string, or an array
with the keys “field” and “value”.
$email = 'user#example.com';
$clause = $db->quoteInto('email = ?', $email);
$validator = new Zend\Validator\Db\RecordExists(
array(
'table' => 'users',
'field' => 'username',
'exclude' => $clause
)
);
if ($validator->isValid($username)) {
// username appears to be valid
} else {
// username is invalid; print the reason
$messages = $validator->getMessages();
foreach ($messages as $message) {
echo "$message\n";
}
}
Second by writing your own custom validtor.
You need to extend AbstractDB class and create your own class on directions of RecordExists Class. In your own cust class your can define your own query and pass it to isValid function.
I have created a Custom Validator oposite to Exclude, which is include.
include is reserve word, Now sure if it will work.
check it here
More readings on this
Guidlines 1
Please have look to existing validtor for creating your own custom validatorCustom validator guildline
Chain validator 2
Can someone tell me how to make a join within magento
Here is the problem:
<?//kleurtjes
$collection= Mage::getModel('faq/faq')->getCollection();
$collection->getSelect()->join(array('faqcat' => $this->getTable('faqcat/faqcat')), 'faqcat.faqcat_id=faq.faqcat_id' , array('faqcat.*'));
?>
i am trying to make a join with the table faqcat where i use the key faqcat_id .
futher i want that faqcat.name + faq.faq_id are being selected cos these are the values i want to use in colums.
<?
protected function _prepareColumns()
{
$this->addColumn('faq_id', array(
'header' => Mage::helper('faq')->__('ID'),
'align' =>'right',
'width' => '50px',
'index' => 'faq_id',
));
$this->addColumn('name', array(
'header' => Mage::helper('faqcat')->__('Titel'),
'align' =>'left',
'index' => 'name',
));
}
?>
after trying 1000 combinations i dont know what to do anymore ... who is willing to help me
this is the complete function:
<?
protected function _prepareCollection()
{
$collection= Mage::getModel('faq/faq')->getCollection();
//$collection->getSelect()->join(array('faqcat' => $this->getTable('faqcat/faqcat')), 'faqcat.faqcat_id=faq.faqcat_id' , array('faqcat.*'));
$id = Mage::getModel('customer/session')->getCustomer()->getId();
$this->setCollection($collection);
// }
return parent::_prepareCollection();
}
?>
just to be clear this is the sql i want to have , but then the magento way
<?//kleurtjes
SELECT faq.faq_id as id, faqcat_name as name
FROM faq
JOIN faqcat
USING ('faqcat_id')
?>
Try this:
$collection->getSelect()
->join($this->getTable('faqcat/faqcat'), "faqcat.faqcat_id = main_table.faqcat_id", array(faqcat.*));
You can see the sql that will actually be run to fetch the collection by:
Mage::log($collection->getSelect()->__toString());
The Varien_Db_Select class is based on Zend_Db_Select, so the Zend documentation is a good reference.
i have just started developing magento extension (loving it) and this is the 2nd part in it where i have to show a grid from two tables. (whew).
but its not that easy after surfing internet a lot i achieved mine result by doing this.
$collection = Mage::getModel('linkdirectory/linkdirectory')->getCollection();
$resource = Mage::getSingleton('core/resource');
$collection->getSelect()
->join(
array('lk'=>$resource->getTableName('linkdirectory/linkcategory')),
'lk.cat_id = main_table.cat_id',
array('lk.cat_title','lk.cat_id')
);
/* mine was showing this */
/SELECT main_table., lk.cat_title, lk.cat_id FROM linkdirectory AS main_table INNER JOIN linkcategory AS lk ON lk.cat_id = main_table.cat_id*/
/* to print the current query */
$collection->printlogquery(true);exit;