Code Duplication    Length = 39-39 lines in 2 locations

class/bbcvols.class.php 1 location

@@ 655-693 (lines=39) @@
652
     *
653
     * @return int New id of clone
654
     */
655
    public function createFromClone($fromid)
656
    {
657
        dol_syslog(__METHOD__, LOG_DEBUG);
658
659
        global $user;
660
        $error = 0;
661
        $object = new Bbcvols($this->db);
662
663
        $this->db->begin();
664
665
        // Load source object
666
        $object->fetch($fromid);
667
        // Reset object
668
        $object->id = 0;
669
670
        // Clear fields
671
        // ...
672
673
        // Create clone
674
        $result = $object->create($user);
675
676
        // Other options
677
        if ($result < 0) {
678
            $error++;
679
            $this->errors = $object->errors;
680
            dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
681
        }
682
683
        // End
684
        if (!$error) {
685
            $this->db->commit();
686
687
            return $object->id;
688
        } else {
689
            $this->db->rollback();
690
691
            return -1;
692
        }
693
    }
694
695
    /**
696
     *  Return a link to the user card (with optionaly the picto)

class/bbctypes.class.php 1 location

@@ 453-491 (lines=39) @@
450
	 *
451
	 * @return int New id of clone
452
	 */
453
	public function createFromClone($fromid)
454
	{
455
		dol_syslog(__METHOD__, LOG_DEBUG);
456
457
		global $user;
458
		$error = 0;
459
		$object = new Bbctypes($this->db);
460
461
		$this->db->begin();
462
463
		// Load source object
464
		$object->fetch($fromid);
465
		// Reset object
466
		$object->id = 0;
467
468
		// Clear fields
469
		// ...
470
471
		// Create clone
472
		$result = $object->create($user);
473
474
		// Other options
475
		if ($result < 0) {
476
			$error ++;
477
			$this->errors = $object->errors;
478
			dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
479
		}
480
481
		// End
482
		if (!$error) {
483
			$this->db->commit();
484
485
			return $object->id;
486
		} else {
487
			$this->db->rollback();
488
489
			return - 1;
490
		}
491
	}
492
493
	/**
494
	 *  Return a link to the user card (with optionaly the picto)