Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2006
    Posts
    385
    Plugin Contributions
    0

    Default Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    Hello All, I have a bit of a problem I can't seem to resolve, I am running 138a and I am tryning to add a module, Purchase orders 3.12 one of the steps is to run a db script.....

    -- DROP TABLE IF EXISTS `subcontractors`;

    CREATE TABLE `subcontractors` (
    `subcontractors_id` int(10) unsigned NOT NULL auto_increment,
    `short_name` varchar(20) NOT NULL default '',
    `full_name` varchar(100) NOT NULL default '',
    `street1` varchar(100) NOT NULL default '',
    `city` varchar(255) NOT NULL default '',
    `state` varchar(255) NOT NULL default '',
    `zip` varchar(10) NOT NULL default '',
    `email_address` varchar(100) NOT NULL default '',
    `telephone` varchar(32) NOT NULL default '',
    `contact_person` varchar(100) NOT NULL default '',
    PRIMARY KEY (`subcontractors_id`)
    ) TYPE=MyISAM COMMENT='subcontractors' AUTO_INCREMENT=0;

    INSERT INTO subcontractors VALUES (0, 'ownstock', 'Own stock', 'Street','City','State','ZIP','email@email.com','telephone','contact name');

    UPDATE subcontractors SET subcontractors_id=0 where short_name='ownstock';

    ALTER TABLE `orders_products`
    ADD `po_sent` char(1) NOT NULL default '0',
    ADD `po_number` int(20),
    ADD `po_sent_to_subcontractor` int(10),
    ADD `po_date` DATE,
    ADD `item_shipped` CHAR(1) NOT NULL default '0';

    ALTER TABLE `products`
    ADD `default_subcontractor` int(10) NOT NULL default '0';

    SET @poid=9999;
    SELECT (@poid:=configuration_group_id) as poid
    FROM configuration_group
    WHERE configuration_group_title= 'Purchase Orders';
    DELETE FROM configuration WHERE configuration_group_id = @poid;
    DELETE FROM configuration_group WHERE configuration_group_id = @poid;

    INSERT INTO configuration_group VALUES ('', 'Purchase Orders', 'Purchase Order Settings', '1', '1');
    UPDATE configuration_group SET sort_order = last_insert_id() WHERE configuration_group_id = last_insert_id();
    SET @poid=9999;
    SELECT (@poid:=configuration_group_id) as poid
    FROM configuration_group
    WHERE configuration_group_title= 'Purchase Orders';

    DELETE FROM configuration WHERE configuration_key='PO_OWN_STOCK_EMAIL';
    DELETE FROM configuration WHERE configuration_key='PO_NOTIFY';
    DELETE FROM configuration WHERE configuration_key='PO_SUBJECT';

    INSERT INTO configuration VALUES ('','PO - send packing lists', 'PO_SEND_PACKING_LISTS', '1', '0 - never, 1 - always, 2 - sometimes (default yes), 3 - sometimes (default no)', @poid, 101, now(), now(), NULL, NULL),
    ('','PO - notify customer', 'PO_NOTIFY', '1', '0 - no customer notification of PO updates, 1 - notify customer', @poid, 102, now(), now(), NULL, NULL),
    ('','PO - subject', 'PO_SUBJECT', '{contact_person}: New order (#{po_number}) for {full_name}', 'Subject of PO emails, {po_number} will be replaced with the actual number', @poid, 103, now(), now(), NULL, NULL),
    ('','PO - from email name', 'PO_FROM_EMAIL_NAME', 'PurchaseOrderManager', 'The FROM email NAME for sent Purchase Orders', @poid, 104, now(), now(), NULL, NULL),
    ('','PO - from email address', 'PO_FROM_EMAIL_ADDRESS', 'po_email@here.com', 'The FROM email ADDRESS for sent Purchase Orders', @poid, 105, now(), now(), NULL, NULL),
    ('','PO - sent comments', 'PO_SENT_COMMENTS', 'Order Submitted to Shipping Department for Fulfillment', 'Comments added to the account when submitted to subcontractor', @poid, 106, now(), now(), NULL, NULL),
    ('','PO - full ship comments', 'PO_FULLSHIP_COMMENTS', 'Thanks for your order!', 'Comments added to the account when the order has shipped in full', @poid, 107, now(), now(), NULL, NULL),
    ('','PO - partial ship comments', 'PO_PARTIALSHIP_COMMENTS', 'Part of your order has shipped! The rest of your order will ship soon. You will be notified by email when your order is complete.', 'Comments added to the account when part of the order has shipped', @poid, 108, now(), now(), NULL, NULL),
    ('','PO - full ship packinglist', 'PO_FULLSHIP_PACKINGLIST', 'Thanks for your order!', 'Comments added to the packing list when the order has shipped in full', @poid, 109, now(), now(), NULL, NULL),
    ('','PO - partial ship packinglist', 'PO_PARTIALSHIP_PACKINGLIST', 'This is a partial shipment. The rest of your order has shipped or will ship separately.', 'Comments added to the packing list when part of the order has shipped', @poid, 110, now(), now(), NULL, NULL),
    ('','PO - packinglist filename', 'PO_PACKINGLIST_FILENAME', 'packinglist.pdf', 'packing list filename', @poid, 111, now(), now(), NULL, NULL),
    ('','PO - omit from unknown email 1', 'PO_UNKNOWN_OMIT1', '\nIf you would prefer to enter tracking information for this order\ndirectly, please visit:\n', 'Text to omit from emails sent for unknown customers 1 of 3', @poid, 112, now(), now(), NULL, NULL),
    ('','PO - omit from unknown email 2', 'PO_UNKNOWN_OMIT2', '{delivery_name}\n', 'Text to omit from emails sent for unknown customers 2 of 3', @poid, 113, now(), now(), NULL, NULL),
    ('','PO - omit from unknown email 3', 'PO_UNKNOWN_OMIT3', '', 'Text to omit from emails sent for unknown customers 3 of 3', @poid, 114, now(), now(), NULL, NULL),
    ('','PO - change shipping from', 'PO_CHANGE_SHIPPING_FROM', '', 'Change this shipping option to something else on POs and Packing Lists', @poid, 115, now(), now(), NULL, NULL),
    ('','PO - change shipping to', 'PO_CHANGE_SHIPPING_TO', 'Cheapest', 'Value to change shipping option to on POs and Packing Lists', @poid, 116, now(), now(), NULL, NULL);

    Upon running the script I get the following error and as such it is not complete..

    1062 Duplicate entry '0' for key 1
    in:
    [UPDATE subcontractors SET subcontractors_id=0 where short_name='ownstock';]
    If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

    The confusing thin is I am running it on my test site which is an identical copy of my functioning site, with a duplicate database. Now running it on the real site I have no problems....I would however like to try and maintain my test site on a par for these exact reasons.

  2. #2

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    Hmmm... The subcontractor_id should already be 0, as it was added as zero in the previous SQL Query. Hence, this command is a bit redundant. Note quite sure why either I or the original author of Purchase Orders 1 included that command at this point. However, it shouldn't cause a problem unless you have two subcontractors with the short name "ownstock". Delete the one who's subcontractor's id is not 0 and that will fix your problem. Or, just drop the table altogether and run the SQL script again.

  3. #3
    Join Date
    Jun 2006
    Posts
    385
    Plugin Contributions
    0

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    Quote Originally Posted by srturner47 View Post
    Hmmm... The subcontractor_id should already be 0, as it was added as zero in the previous SQL Query. Hence, this command is a bit redundant. Note quite sure why either I or the original author of Purchase Orders 1 included that command at this point. However, it shouldn't cause a problem unless you have two subcontractors with the short name "ownstock". Delete the one who's subcontractor's id is not 0 and that will fix your problem. Or, just drop the table altogether and run the SQL script again.
    This is correct, many thanks it worked Ok for me. If I can ask one more question about this programme, if used in conjunction with an easy populate programme to mass edit the products, how do you cover selecting the subcontractors....Please dont tell me its a manual select for each one....Is there a way of using the top subcontractor as a default....

    Thank you

    Best Regards
    RR

  4. #4

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    Sorry, but you'd need to assign a subcontractor for each one. Easy populate won't do this --- or, just pick the subcontractor when sending POs. The assignments are just defaults, you can always override them when sending POs.

  5. #5
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    9,916
    Plugin Contributions
    3

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    I do not know the inner workings of the module, so what I say below may have no relevance.

    I notice in the SQL, that a field is added to the products table:

    Code:
    ALTER TABLE `products`
    ADD `default_subcontractor` int(10) NOT NULL default '0';
    Because EP works with the product tables, it IS possible to add a new field to your easy populate.

    http://www.zen-cart.com/forum/showthread.php?t=116061

    HOWEVER... the core data for your subcontractors is NOT governed by the products table, but by the subcontractors table, so any data that you put into easypopulate (I believe) should ALREADY be in your subcontractors tables. (In other words, you cannot ADD subcontractor data using easypopulate... you can only get it to reflect the default subcontractor.

    Before you rush headlong into this, think carefully.

    All I am saying is that it is possible to add fields to EP - if these fields are in the products table...
    http://www.zen-cart.com/forum/showthread.php?t=116061
    Did my post help you fix something? You can show your gratitude by buying the the dev team coffee.

  6. #6

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    Yes you are correct schoolboy. It will use the default subcontractor no matter how you add the item -- easy populate, regular add from admin, etc... This is a good point.

    Also, if you add a subcontractor's products all at the same time, the id numbers for the products should be in order. This would make it really easy to create your own SQL command to change the subcontractor for this range of product id numbers.

  7. #7
    Join Date
    Aug 2009
    Posts
    211
    Plugin Contributions
    1

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    I have installed this mod and am getting the following when I try to send a PO:
    FPDF error: Image file has no extension and no type was specified: PO_PDFP_PICTURE_ONE_FILE
    Has anyone had and solved the issue? Ideas?

  8. #8
    Join Date
    Aug 2009
    Posts
    211
    Plugin Contributions
    1

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    Quote Originally Posted by ksookma View Post
    I have installed this mod and am getting the following when I try to send a PO:
    FPDF error: Image file has no extension and no type was specified: PO_PDFP_PICTURE_ONE_FILE
    Has anyone had and solved the issue? Ideas?
    I think I just need to uninstall the SQL and reinstall... is there an uninstall script out there... would not want to go through the whole thing manually.

  9. #9
    Join Date
    Aug 2009
    Posts
    211
    Plugin Contributions
    1

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    Fixed! I removed the first part and just ran this:
    INSERT INTO configuration VALUES
    ('','PO - PDF Packing List - first picture filename', 'PO_PDFP_PICTURE_ONE_FILE', '', 'First Picture Filename to Add to PDF Packing List - Store file in admin directory. Leave blank for no picture. Supported files include .gif, .jpg, and .png.', @poid, 380, now(), now(), NULL, NULL),
    ('','PO - PDF Packing List - first picture location (mm)', 'PO_PDFP_PICTURE_ONE_LOCATION', '15,15', 'First Picture Location on PDF Packing List - x,y for top left corner of image in mm -> x is mm from left of page, y is mm from top of page. FYI - Standard page is 215.9mm wide and 279.4mm high.', @poid, 385, now(), now(), NULL, NULL),
    ('','PO - PDF Packing List - first picture width (mm)', 'PO_PDFP_PICTURE_ONE_WIDTH', '45', 'Width of first picture in mm. Height is calculated automatically and keeps picture proportional.', @poid, 390, now(), now(), NULL, NULL),
    ('','PO - PDF Packing List - second picture filename', 'PO_PDFP_PICTURE_TWO_FILE', '', 'Second Picture Filename to Add to PDF Packing List - Store file in admin directory. Leave blank for no picture. Supported files include .gif, .jpg, and .png.', @poid, 395, now(), now(), NULL, NULL),
    ('','PO - PDF Packing List - second picture location (mm)', 'PO_PDFP_PICTURE_TWO_LOCATION', '85.45,190', 'Second Picture Location on PDF Packing List - x,y for top left corner of image in mm -> x is mm from left of page, y is mm from top of page. FYI - Standard page is 215.9mm wide and 279.4mm high.', @poid, 400, now(), now(), NULL, NULL),
    ('','PO - PDF Packing List - second picture width (mm)', 'PO_PDFP_PICTURE_TWO_WIDTH', '45', 'Width of first picture in mm. Height is calculated automatically and keeps picture proportional.', @poid, 405, now(), now(), NULL, NULL);


  10. #10
    Join Date
    Aug 2009
    Posts
    211
    Plugin Contributions
    1

    Default Re: Purchase orders 3.12 -- Problem: 1062 Duplicate entry '0' for key 1

    quick note: I missed some statements but basically the sql didn't run due to duplicated values. So I am running the statements one at a time to get them all in. Im sure there is a better way to do this but it works.

 

 

Similar Threads

  1. 1062 Duplicate entry 'Customers who have never completed a purchase' for key 2
    By elliesupport in forum Upgrading from 1.3.x to 1.3.9
    Replies: 1
    Last Post: 2 Jul 2008, 09:04 PM
  2. 1062 Duplicate entry '38' for key 1
    By henryvuong in forum General Questions
    Replies: 1
    Last Post: 16 Jan 2008, 06:40 AM
  3. 1062 Duplicate entry '3-1' for key 1 PROBLEM with meta tags
    By paulFromWales in forum General Questions
    Replies: 2
    Last Post: 4 Oct 2006, 04:15 PM
  4. 1062 Duplicate entry '2-1' for key 1
    By clr in forum General Questions
    Replies: 1
    Last Post: 18 May 2006, 04:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •